This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bugs revealed by replacing (SV *) casts with something that doesn't
authorNicholas Clark <nick@ccl4.org>
Mon, 27 Oct 2008 20:22:36 +0000 (20:22 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 27 Oct 2008 20:22:36 +0000 (20:22 +0000)
cast away const - AvFILL() doesn't guarantee that it won't modify the
AV * passed to it. So the prototype for Perl_av_len() needs to change,
and a const needs to go in Perl_magic_setarraylen().

p4raw-id: //depot/perl@34604

av.c
embed.fnc
mg.c
proto.h

diff --git a/av.c b/av.c
index b2c1aae..a31a8be 100644 (file)
--- a/av.c
+++ b/av.c
@@ -758,7 +758,7 @@ array is C<av_len(av) + 1>.  Returns -1 if the array is empty.
 */
 
 I32
-Perl_av_len(pTHX_ register const AV *av)
+Perl_av_len(pTHX_ AV *av)
 {
     PERL_ARGS_ASSERT_AV_LEN;
     assert(SvTYPE(av) == SVt_PVAV);
index d9b5f22..78c4f19 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -112,7 +112,7 @@ Apd |void   |av_extend      |NN AV *av|I32 key
 pR     |AV*    |av_fake        |I32 size|NN SV **strp
 ApdR   |SV**   |av_fetch       |NN AV *av|I32 key|I32 lval
 Apd    |void   |av_fill        |NN AV *av|I32 fill
-ApdR   |I32    |av_len         |NN const AV *av
+ApdR   |I32    |av_len         |NN AV *av
 ApdR   |AV*    |av_make        |I32 size|NN SV **strp
 Apd    |SV*    |av_pop         |NN AV *av
 ApdoxM |void   |av_create_and_push|NN AV **const avp|NN SV *const val
diff --git a/mg.c b/mg.c
index b34257d..643ec7e 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1895,7 +1895,7 @@ int
 Perl_magic_getarylen(pTHX_ SV *sv, const MAGIC *mg)
 {
     dVAR;
-    const AV * const obj = (AV*)mg->mg_obj;
+    AV * const obj = (AV*)mg->mg_obj;
 
     PERL_ARGS_ASSERT_MAGIC_GETARYLEN;
 
diff --git a/proto.h b/proto.h
index ca19956..0d7d9a4 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -192,7 +192,7 @@ PERL_CALLCONV void  Perl_av_fill(pTHX_ AV *av, I32 fill)
 #define PERL_ARGS_ASSERT_AV_FILL       \
        assert(av)
 
-PERL_CALLCONV I32      Perl_av_len(pTHX_ const AV *av)
+PERL_CALLCONV I32      Perl_av_len(pTHX_ AV *av)
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_AV_LEN        \