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

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

Thread Previous
From:
l . mai @ web . de
Date:
September 28, 2013 22:17
Subject:
[perl #120043] [PATCH] 38b73da fix a few warnings (format strings, unused variable)
Message ID:
rt-3.6.HEAD-31239-1380406600-1288.120043-75-0@perl.org
# New Ticket Created by  l.mai@web.de 
# Please include the string:  [perl #120043]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=120043 >



This is a bug report for perl from l.mai@web.de,
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 <l.mai@web.de>
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="------------1.8.1.5"

This is a multi-part message in MIME format.
--------------1.8.1.5
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(-)


--------------1.8.1.5
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;
     }
     my_exit_jump();
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 */
 
         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:

--------------1.8.1.5--


---
Flags:
    category=core
    severity=low
---
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
  Platform:
    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
  Compiler:
    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/libc-2.15.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.15'
  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:
    lib
    /usr/local/lib/perl5/site_perl/5.19.5/i686-linux
    /usr/local/lib/perl5/site_perl/5.19.5
    /usr/local/lib/perl5/5.19.5/i686-linux
    /usr/local/lib/perl5/5.19.5
    .

---
Environment for perl 5.19.5:
    HOME=/home/mauke
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_COLLATE=POSIX
    LD_LIBRARY_PATH=/home/mauke/usr/local/lib
    LOGDIR (unset)
    PATH=/home/mauke/usr/perlbrew/bin:/home/mauke/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.6.3:/opt/sun-jdk-1.4.2.13/bin:/opt/sun-jdk-1.4.2.13/jre/bin:/opt/sun-jdk-1.4.2.13/jre/javaws:/opt/dmd/bin:/usr/games/bin
    PERLBREW_BASHRC_VERSION=0.43
    PERLBREW_HOME=/home/mauke/.perlbrew
    PERLBREW_PATH=/home/mauke/usr/perlbrew/bin
    PERLBREW_ROOT=/home/mauke/usr/perlbrew
    PERLBREW_VERSION=0.27
    PERL_BADLANG (unset)
    PERL_UNICODE=SAL
    SHELL=/bin/bash


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About