develooper Front page | perl.perl5.porters | Postings from September 2013

[perl #120043] [PATCH] 38b73da fix a few warnings (format strings, unused variable)

Thread Previous
l . mai @ web . de
September 28, 2013 22:17
[perl #120043] [PATCH] 38b73da fix a few warnings (format strings, unused variable)
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #120043]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.39 running under perl 5.19.5.

>From 38b73daa7c055f31a9b9cd9770833a1f022fc406 Mon Sep 17 00:00:00 2001
From: Lukas Mai <>
Date: Sun, 29 Sep 2013 00:12:44 +0200
Subject: [PATCH] fix a few warnings (format strings, unused variable)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------"

This is a multi-part message in MIME format.
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

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.
 mg.c      | 2 +-
 perl.c    | 4 ++--
 pp_ctl.c  | 1 -
 regexec.c | 2 +-
 4 files changed, 4 insertions(+), 5 deletions(-)

Content-Type: text/x-patch; name="0001-fix-a-few-warnings-format-strings-unused-variable.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-fix-a-few-warnings-format-strings-unused-variable.patch"

diff --git a/mg.c b/mg.c
index 93048ec..3188f89 100644
--- 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 e9cf22a..b2834f0 100644
--- a/perl.c
+++ b/perl.c
@@ -4967,7 +4967,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) {
@@ -5072,7 +5072,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;
diff --git a/pp_ctl.c b/pp_ctl.c
index f258976..ded6c90 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2607,7 +2607,6 @@ PP(pp_last)
     OP *nextop = NULL;
     SV **newsp;
     PMOP *newpm;
-    SV **mark;
     SV *sv = NULL;
     S_unwind_loop(aTHX_ "last");
diff --git a/regexec.c b/regexec.c
index fd9f01c..042ee85 100644
--- a/regexec.c
+++ b/regexec.c
@@ -2273,7 +2273,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
             : strbeg; /* pos() not defined; use start of string */
-            "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:


Site configuration information for perl 5.19.5:

Configured by mauke at Sat Sep 28 23:34:30 CEST 2013.

Summary of my perl5 (revision 5 version 19 subversion 5) configuration:
  Commit id: 6d76e7fc723ef1780fb1cb21c20437473219e384
    osname=linux, osvers=3.5.7-gentoo, archname=i686-linux
    uname='linux nora 3.5.7-gentoo #5 preempt sat jan 26 16:46:10 cet 2013 i686 amd athlon(tm) 64 processor 3200+ authenticamd gnulinux '
    config_args='-Dusedevel -DDEBUGGING -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.8.1', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib -fstack-protector'

@INC for perl 5.19.5:

Environment for perl 5.19.5:
    LANGUAGE (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About