This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8.c: Silence compiler warning
[perl5.git] / dump.c
diff --git a/dump.c b/dump.c
index b5998f9..ae0ca1e 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -181,7 +181,7 @@ Perl_pv_escape( pTHX_ SV *dsv, char const * const str,
                chsize = 2;
                 switch (c) {
                 
-               case '\\' : /* fallthrough */
+               case '\\' : /* FALLTHROUGH */
                case '%'  : if ( c == esc )  {
                                octbuf[1] = esc;  
                            } else {
@@ -471,7 +471,7 @@ Perl_sv_peek(pTHX_ SV *sv)
   finish:
     while (unref--)
        sv_catpv(t, ")");
-    if (TAINTING_get && SvTAINTED(sv))
+    if (TAINTING_get && sv && SvTAINTED(sv))
        sv_catpv(t, " [tainted]");
     return SvPV_nolen(t);
 }
@@ -868,8 +868,7 @@ const struct op_private_by_op op_private_names[] = {
 static bool
 S_op_private_to_names(pTHX_ SV *tmpsv, U32 optype, U32 op_private) {
     const struct op_private_by_op *start = op_private_names;
-    const struct op_private_by_op *const end
-       = op_private_names + C_ARRAY_LENGTH(op_private_names);
+    const struct op_private_by_op *const end = C_ARRAY_END(op_private_names);
 
     /* This is a linear search, but no worse than the code that it replaced.
        It's debugging code - size is more important than speed.  */
@@ -1665,7 +1664,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
                sv_catpv(d, " ),");
            }
        }
-       /* FALL THROUGH */
+       /* FALLTHROUGH */
     default:
     evaled_or_uv:
        if (SvEVALED(sv))       sv_catpv(d, "EVALED,");
@@ -1676,7 +1675,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
        if (SvVALID(sv))        sv_catpv(d, "VALID,");
        if (SvPAD_TYPED(sv))    sv_catpv(d, "TYPED,");
        if (SvPAD_OUR(sv))      sv_catpv(d, "OUR,");
-       /* FALL THROUGH */
+       /* FALLTHROUGH */
     case SVt_PVNV:
        if (SvPAD_STATE(sv))    sv_catpv(d, "STATE,");
        goto evaled_or_uv;
@@ -1882,20 +1881,22 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
            }
        }
        break;
-    case SVt_PVHV:
+    case SVt_PVHV: {
+       U32 usedkeys;
         if (SvOOK(sv)) {
             struct xpvhv_aux *const aux = HvAUX(sv);
             Perl_dump_indent(aTHX_ level, file, "  AUX_FLAGS = %"UVuf"\n",
                              (UV)aux->xhv_aux_flags);
         }
        Perl_dump_indent(aTHX_ level, file, "  ARRAY = 0x%"UVxf, PTR2UV(HvARRAY(sv)));
-       if (HvARRAY(sv) && HvUSEDKEYS(sv)) {
+       usedkeys = HvUSEDKEYS(sv);
+       if (HvARRAY(sv) && usedkeys) {
            /* Show distribution of HEs in the ARRAY */
            int freq[200];
-#define FREQ_MAX ((int)(sizeof freq / sizeof freq[0] - 1))
+#define FREQ_MAX ((int)(C_ARRAY_LENGTH(freq) - 1))
            int i;
            int max = 0;
-           U32 pow2 = 2, keys = HvUSEDKEYS(sv);
+           U32 pow2 = 2, keys = usedkeys;
            NV theoret, sum = 0;
 
            PerlIO_printf(file, "  (");
@@ -1937,13 +1938,13 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
             }
            while ((keys = keys >> 1))
                pow2 = pow2 << 1;
-           theoret = HvUSEDKEYS(sv);
+           theoret = usedkeys;
            theoret += theoret * (theoret-1)/pow2;
            PerlIO_putc(file, '\n');
            Perl_dump_indent(aTHX_ level, file, "  hash quality = %.1"NVff"%%", theoret/sum*100);
        }
        PerlIO_putc(file, '\n');
-       Perl_dump_indent(aTHX_ level, file, "  KEYS = %"IVdf"\n", (IV)HvUSEDKEYS(sv));
+       Perl_dump_indent(aTHX_ level, file, "  KEYS = %"IVdf"\n", (IV)usedkeys);
         {
             STRLEN count = 0;
             HE **ents = HvARRAY(sv);
@@ -2116,6 +2117,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
            }
        }
        break;
+    } /* case SVt_PVHV */
 
     case SVt_PVCV:
        if (CvAUTOLOAD(sv)) {
@@ -2132,7 +2134,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
                             generic_pv_escape(tmpsv, proto, CvPROTOLEN(sv),
                                 SvUTF8(sv)));
        }
-       /* FALL THROUGH */
+       /* FALLTHROUGH */
     case SVt_PVFM:
        do_hv_dump(level, file, "  COMP_STASH", CvSTASH(sv));
        if (!CvISXSUB(sv)) {