This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In S_mro_get_linear_isa_dfs(), add void casts to silence two warnings
authorNicholas Clark <nick@ccl4.org>
Fri, 12 Sep 2008 21:02:55 +0000 (21:02 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 12 Sep 2008 21:02:55 +0000 (21:02 +0000)
about "value computed is not used". Re-order the code to group
operations on the isa hash with each other. Add a SvREADONLY_on() on
the isa array if it is generated by Perl_get_isa_hash().

p4raw-id: //depot/perl@34357

mro.c

diff --git a/mro.c b/mro.c
index b15ec3a..f2cbee3 100644 (file)
--- a/mro.c
+++ b/mro.c
@@ -124,6 +124,8 @@ Perl_get_isa_hash(pTHX_ HV *const stash)
                             HEK_HASH(canon_name));
            (void) hv_store(isa_hash, "UNIVERSAL", 9, &PL_sv_undef, 0);
 
+           SvREADONLY_on(isa_hash);
+
            meta->isa = isa_hash;
        }
     }
@@ -259,24 +261,26 @@ S_mro_get_linear_isa_dfs(pTHX_ HV *stash, I32 level)
         }
     }
 
+    (void) hv_store_ent(stored, our_name, &PL_sv_undef, 0);
+    (void) hv_store(stored, "UNIVERSAL", 9, &PL_sv_undef, 0);
+
+    SvREFCNT_inc_simple_void_NN(stored);
+    SvTEMP_off(stored);
+    SvREADONLY_on(stored);
+
+    meta->isa = stored;
+
     /* now that we're past the exception dangers, grab our own reference to
        the AV we're about to use for the result. The reference owned by the
        mortals' stack will be released soon, so everything will balance.  */
     SvREFCNT_inc_simple_void_NN(retval);
     SvTEMP_off(retval);
-    SvREFCNT_inc_simple_void_NN(stored);
-    SvTEMP_off(stored);
-
-    hv_store_ent(stored, our_name, &PL_sv_undef, 0);
-    hv_store(stored, "UNIVERSAL", 9, &PL_sv_undef, 0);
 
     /* we don't want anyone modifying the cache entry but us,
        and we do so by replacing it completely */
     SvREADONLY_on(retval);
-    SvREADONLY_on(stored);
 
     meta->mro_linear_dfs = retval;
-    meta->isa = stored;
     return retval;
 }