This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix a few warnings (format strings, unused variable)
authorLukas Mai <l.mai@web.de>
Sat, 28 Sep 2013 22:12:44 +0000 (00:12 +0200)
committerTony Cook <tony@develop-help.com>
Wed, 20 Nov 2013 03:20:31 +0000 (14:20 +1100)
During compilation gcc complains about the following:

perl.c:4970: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'U32' [-Wformat=]
perl.c:5075: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'I32' [-Wformat=]
mg.c:1972: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'ssize_t' [-Wformat=]
pp_ctl.c:2610: warning: unused variable 'mark' [-Wunused-variable]
regexec.c:2275: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'int' [-Wformat=]

This patch fixes all of them.

Tony: warning: unused variable 'mark' was fixed in 481c819b

mg.c
perl.c
regexec.c

diff --git a/mg.c b/mg.c
index e8d22a3..7c10bd5 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1969,7 +1969,7 @@ Perl_magic_setdbline(pTHX_ SV *sv, MAGIC *mg)
     /* The magic ptr/len for the debugger's hash should always be an SV.  */
     if (UNLIKELY(mg->mg_len != HEf_SVKEY)) {
         Perl_croak(aTHX_ "panic: magic_setdbline len=%"IVdf", ptr='%s'",
-                   mg->mg_len, mg->mg_ptr);
+                   (IV)mg->mg_len, mg->mg_ptr);
     }
 
     /* Use sv_2iv instead of SvIV() as the former generates smaller code, and
diff --git a/perl.c b/perl.c
index e4310cd..b551d45 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -4902,7 +4902,7 @@ Perl_my_exit(pTHX_ U32 status)
     }
     if (PL_exit_flags & PERL_EXIT_WARN) {
        PL_exit_flags |= PERL_EXIT_ABORT; /* Protect against reentrant calls */
-       Perl_warn(aTHX_ "Unexpected exit %u", status);
+       Perl_warn(aTHX_ "Unexpected exit %lu", (unsigned long)status);
        PL_exit_flags &= ~PERL_EXIT_ABORT;
     }
     switch (status) {
@@ -5007,7 +5007,7 @@ Perl_my_failure_exit(pTHX)
     }
     if (PL_exit_flags & PERL_EXIT_WARN) {
        PL_exit_flags |= PERL_EXIT_ABORT; /* Protect against reentrant calls */
-       Perl_warn(aTHX_ "Unexpected exit failure %u", PL_statusvalue);
+       Perl_warn(aTHX_ "Unexpected exit failure %ld", (long)PL_statusvalue);
        PL_exit_flags &= ~PERL_EXIT_ABORT;
     }
     my_exit_jump();
index acca274..6de1783 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -2283,7 +2283,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
             : strbeg; /* pos() not defined; use start of string */
 
         DEBUG_GPOS_r(PerlIO_printf(Perl_debug_log,
-            "GPOS ganch set to strbeg[%"IVdf"]\n", reginfo->ganch - strbeg));
+            "GPOS ganch set to strbeg[%"IVdf"]\n", (IV)(reginfo->ganch - strbeg)));
 
         /* in the presence of \G, we may need to start looking earlier in
          * the string than the suggested start point of stringarg: