mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 16:39:36 +00:00
fix type of Perl_magic_getarylen
This function is used as part of PL_magic_vtables, so its type must be 'int (pTHX_ SV *, MAGIC *)' exactly (no const). With the right type, we no longer need an ad-hoc cast in mg_vtables.h, which means we no longer need the 'const' code in regen/mg_vtable.pl, which was a special case used by this one function only. Should fix ASan complaints about functions being called with incorrect types.
This commit is contained in:
parent
c20901a4e7
commit
3677d5e890
@ -1909,7 +1909,7 @@ p |int |magic_freeutf8 |NN SV *sv \
|
||||
p |int |magic_get |NN SV *sv \
|
||||
|NN MAGIC *mg
|
||||
p |int |magic_getarylen|NN SV *sv \
|
||||
|NN const MAGIC *mg
|
||||
|NN MAGIC *mg
|
||||
p |int |magic_getdebugvar \
|
||||
|NN SV *sv \
|
||||
|NN MAGIC *mg
|
||||
|
||||
2
mg.c
2
mg.c
@ -2364,7 +2364,7 @@ Perl_magic_setdbline(pTHX_ SV *sv, MAGIC *mg)
|
||||
}
|
||||
|
||||
int
|
||||
Perl_magic_getarylen(pTHX_ SV *sv, const MAGIC *mg)
|
||||
Perl_magic_getarylen(pTHX_ SV *sv, MAGIC *mg)
|
||||
{
|
||||
AV * const obj = MUTABLE_AV(mg->mg_obj);
|
||||
|
||||
|
||||
2
mg_vtable.h
generated
2
mg_vtable.h
generated
@ -165,7 +165,7 @@ EXTCONST char * const PL_magic_vtable_names[magic_vtable_max];
|
||||
|
||||
#ifdef DOINIT
|
||||
EXT_MGVTBL PL_magic_vtables[magic_vtable_max] = {
|
||||
{ (int (*)(pTHX_ SV *, MAGIC *))Perl_magic_getarylen, Perl_magic_setarylen, 0, 0, 0, 0, 0, 0 },
|
||||
{ Perl_magic_getarylen, Perl_magic_setarylen, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, Perl_magic_cleararylen_p, Perl_magic_freearylen_p, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, Perl_magic_killbackrefs, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, Perl_magic_copycallchecker, 0, 0 },
|
||||
|
||||
2
proto.h
generated
2
proto.h
generated
@ -2207,7 +2207,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
|
||||
assert(sv); assert(mg)
|
||||
|
||||
PERL_CALLCONV int
|
||||
Perl_magic_getarylen(pTHX_ SV *sv, const MAGIC *mg)
|
||||
Perl_magic_getarylen(pTHX_ SV *sv, MAGIC *mg)
|
||||
__attribute__visibility__("hidden");
|
||||
#define PERL_ARGS_ASSERT_MAGIC_GETARYLEN \
|
||||
assert(sv); assert(mg)
|
||||
|
||||
@ -245,11 +245,6 @@ my %mg =
|
||||
# prefix the vtable with the specified entry (e.g. '#ifdef FOO')
|
||||
# and suffix it with '#else { 0, 0, 0, 0, 0, 0, 0, 0 } #endif'
|
||||
#
|
||||
# const
|
||||
# special-case cast a 'get' function whose signature expects
|
||||
# a pointer to constant magic, so that it can be added to a vtable
|
||||
# which expects pointers to functions without the 'const'.
|
||||
#
|
||||
# get
|
||||
# set
|
||||
# len
|
||||
@ -277,7 +272,7 @@ my %vtable_conf =
|
||||
'dbline' => {set => 'setdbline'},
|
||||
'isa' => {set => 'setisa', clear => 'clearisa'},
|
||||
'isaelem' => {set => 'setisa'},
|
||||
'arylen' => {get => 'getarylen', set => 'setarylen', const => 1},
|
||||
'arylen' => {get => 'getarylen', set => 'setarylen'},
|
||||
'arylen_p' => {clear => 'cleararylen_p', free => 'freearylen_p'},
|
||||
'mglob' => {set => 'setmglob',
|
||||
free => 'freemglob' },
|
||||
@ -528,7 +523,6 @@ while (my $name = shift @names) {
|
||||
$data->{$_} ? "Perl_magic_$data->{$_}" : 0;
|
||||
} qw(get set len clear free copy dup local);
|
||||
|
||||
$funcs[0] = "(int (*)(pTHX_ SV *, MAGIC *))" . $funcs[0] if $data->{const};
|
||||
my $funcs = join ", ", @funcs;
|
||||
|
||||
# Because we can't have a , after the last {...}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user