configure: add -Wno-format-truncation to QEMU_CFLAGS
diff mbox

Message ID 20170720145729.22141-1-otubo@redhat.com
State New
Headers show

Commit Message

Eduardo Otubo July 20, 2017, 2:57 p.m. UTC
Compilation breaks on GCC 7.1.1 20170622 (Fedora 26), thus adding
-Wno-format-truncation to QEMU_CFLAGS on configure script is neecssary.

    hw/usb/bus.c: In function ‘usb_port_location’:
    hw/usb/bus.c:410:66: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 15 [-Werror=format-truncation=]
             snprintf(downstream->path, sizeof(downstream->path), "%s.%d",
                                                                      ^~
    In file included from /usr/include/stdio.h:939:0,
                     from /home/otubo/develop/qemu/otubo/include/qemu/osdep.h:68,
                     from hw/usb/bus.c:1:
    /usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 3 and 28 bytes into a destination of size 16
       return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            __bos (__s), __fmt, __va_arg_pack ());
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    make: *** [/home/otubo/develop/qemu/otubo/rules.mak:66: hw/usb/bus.o] Error 1
    make: *** Waiting for unfinished jobs....

Signed-off-by: Eduardo Otubo <otubo@redhat.com>
---
This warning looks pretty much bogus to me. Since building with -Werror is
essential, we should add this flag to configure. If someone thinks this warning
is not a false positive, feel free to drop this patch.
 configure | 1 +
 1 file changed, 1 insertion(+)

Comments

no-reply@patchew.org July 20, 2017, 3:23 p.m. UTC | #1
Hi,

This series failed build test on FreeBSD host. Please find the details below.

Type: series
Message-id: 20170720145729.22141-1-otubo@redhat.com
Subject: [Qemu-devel] [PATCH] configure: add -Wno-format-truncation to QEMU_CFLAGS

=== TEST SCRIPT BEGIN ===
#!/bin/sh
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
set -e
echo "=== ENV ==="
env
echo "=== PACKAGES ==="
pkg info
echo "=== TEST BEGIN ==="
CC=/usr/local/libexec/ccache/cc
INSTALL=$PWD/install
BUILD=$PWD/build
echo -n "Using CC: "
realpath $CC
mkdir -p $BUILD $INSTALL
SRC=$PWD
cd $BUILD
$SRC/configure --cc=$CC --prefix=$INSTALL --target-list=x86_64-softmmu
gmake -j4
# XXX: we need reliable clean up
# make check -j4 V=1
gmake install
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20170720145729.22141-1-otubo@redhat.com -> patchew/20170720145729.22141-1-otubo@redhat.com
Switched to a new branch 'test'
134434f502 configure: add -Wno-format-truncation to QEMU_CFLAGS

=== OUTPUT BEGIN ===
=== ENV ===
LOGNAME=patchew-tester
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
PWD=/var/tmp/patchew-tester-tmp-sjrxxr47/src
HOME=/home/patchew-tester
USER=patchew-tester
SHELL=/bin/sh
PATCHEW=/home/patchew-tester/patchew/patchew-cli -s http://patchew.org --nodebug
=== PACKAGES ===
bash-4.4.12_2                  GNU Project's Bourne Again SHell
binutils-2.28,1                GNU binary tools
bison-3.0.4,1                  Parser generator from FSF, (mostly) compatible with Yacc
ca_root_nss-3.30.2             Root certificate bundle from the Mozilla Project
ccache-3.3.4_3                 Tool to minimize the compile time of C/C++ programs
curl-7.54.0                    Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
cvsps-2.1_2                    Create patchset information from CVS
dtc-1.4.2_1                    Device Tree Compiler
expat-2.2.0_1                  XML 1.0 parser written in C
gcc-5.4.0                      GNU Compiler Collection 5
gcc-ecj-4.5                    Eclipse Java Compiler used to build GCC Java
gettext-runtime-0.19.8.1_1     GNU gettext runtime libraries and programs
git-2.13.0                     Distributed source code management tool
glib-2.46.2_5                  Some useful routines of C programming (current stable version)
gmake-4.2.1_1                  GNU version of 'make' utility
gmp-6.1.2                      Free library for arbitrary precision arithmetic
indexinfo-0.2.6                Utility to regenerate the GNU info page index
libffi-3.2.1                   Foreign Function Interface
libiconv-1.14_10               Character set conversion library
libnghttp2-1.21.0              HTTP/2.0 C Library
m4-1.4.18,1                    GNU M4
mpc-1.0.3                      Library of complex numbers with arbitrarily high precision
mpfr-3.1.5_1                   Library for multiple-precision floating-point computations
p5-Authen-SASL-2.16_1          Perl5 module for SASL authentication
p5-Digest-HMAC-1.03_1          Perl5 interface to HMAC Message-Digest Algorithms
p5-Error-0.17024               Error/exception handling in object-oriented programming style
p5-GSSAPI-0.28_1               Perl extension providing access to the GSSAPIv2 library
pcre-8.40                      Perl Compatible Regular Expressions library
perl5-5.24.1                   Practical Extraction and Report Language
pixman-0.34.0                  Low-level pixel manipulation library
pkg-1.10.1                     Package manager
pkgconf-1.3.0,1                Utility to help to configure compiler and linker flags
python-2.7_3,2                 "meta-port" for the default version of Python interpreter
python2-2_3                    The "meta-port" for version 2 of the Python interpreter
python27-2.7.13_3              Interpreted object-oriented programming language
python3-3_3                    The "meta-port" for version 3 of the Python interpreter
python35-3.5.3_1               Interpreted object-oriented programming language
readline-6.3.8                 Library for editing command lines as they are typed
sudo-1.8.20p1                  Allow others to run commands as root
=== TEST BEGIN ===
Using CC: /usr/local/bin/ccache

ERROR: Your compiler does not support the __thread specifier for 
       Thread-Local Storage (TLS). Please upgrade to a version that does.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
Daniel P. Berrangé July 20, 2017, 3:33 p.m. UTC | #2
On Thu, Jul 20, 2017 at 04:57:29PM +0200, Eduardo Otubo wrote:
> Compilation breaks on GCC 7.1.1 20170622 (Fedora 26), thus adding
> -Wno-format-truncation to QEMU_CFLAGS on configure script is neecssary.
> 
>     hw/usb/bus.c: In function ‘usb_port_location’:
>     hw/usb/bus.c:410:66: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 15 [-Werror=format-truncation=]
>              snprintf(downstream->path, sizeof(downstream->path), "%s.%d",
>                                                                       ^~
>     In file included from /usr/include/stdio.h:939:0,
>                      from /home/otubo/develop/qemu/otubo/include/qemu/osdep.h:68,
>                      from hw/usb/bus.c:1:
>     /usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 3 and 28 bytes into a destination of size 16
>        return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
>               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>             __bos (__s), __fmt, __va_arg_pack ());
>             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     cc1: all warnings being treated as errors
>     make: *** [/home/otubo/develop/qemu/otubo/rules.mak:66: hw/usb/bus.o] Error 1
>     make: *** Waiting for unfinished jobs....
> 
> Signed-off-by: Eduardo Otubo <otubo@redhat.com>
> ---
> This warning looks pretty much bogus to me. Since building with -Werror is
> essential, we should add this flag to configure. If someone thinks this warning
> is not a false positive, feel free to drop this patch.

This particular case of the warning may be a false positive, but the
-Wformat-truncation warning *can* detect serious real bugs so turning
it off is not appropriate. In any case there's a patch this problem
queued for merge already:

https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg06455.html


Regards,
Daniel
Eduardo Otubo July 20, 2017, 4:02 p.m. UTC | #3
On 07/20/2017 05:33 PM, Daniel P. Berrange wrote:
> On Thu, Jul 20, 2017 at 04:57:29PM +0200, Eduardo Otubo wrote:
>> Compilation breaks on GCC 7.1.1 20170622 (Fedora 26), thus adding
>> -Wno-format-truncation to QEMU_CFLAGS on configure script is neecssary.
>>
>>      hw/usb/bus.c: In function ‘usb_port_location’:
>>      hw/usb/bus.c:410:66: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 15 [-Werror=format-truncation=]
>>               snprintf(downstream->path, sizeof(downstream->path), "%s.%d",
>>                                                                        ^~
>>      In file included from /usr/include/stdio.h:939:0,
>>                       from /home/otubo/develop/qemu/otubo/include/qemu/osdep.h:68,
>>                       from hw/usb/bus.c:1:
>>      /usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 3 and 28 bytes into a destination of size 16
>>         return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
>>                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>              __bos (__s), __fmt, __va_arg_pack ());
>>              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>      cc1: all warnings being treated as errors
>>      make: *** [/home/otubo/develop/qemu/otubo/rules.mak:66: hw/usb/bus.o] Error 1
>>      make: *** Waiting for unfinished jobs....
>>
>> Signed-off-by: Eduardo Otubo <otubo@redhat.com>
>> ---
>> This warning looks pretty much bogus to me. Since building with -Werror is
>> essential, we should add this flag to configure. If someone thinks this warning
>> is not a false positive, feel free to drop this patch.
> 
> This particular case of the warning may be a false positive, but the
> -Wformat-truncation warning *can* detect serious real bugs so turning
> it off is not appropriate. In any case there's a patch this problem
> queued for merge already:
> 
> https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg06455.html
> 

Interesting how the `quick search' feature on Thunderbird didn't catch 
this one. Well, thanks anyway for the reply. Let's drop this one, then.

Patch
diff mbox

diff --git a/configure b/configure
index befebe27e3..5d5507b3a0 100755
--- a/configure
+++ b/configure
@@ -482,6 +482,7 @@  ARFLAGS="${ARFLAGS-rv}"
 # left shift of signed integers is well defined and has the expected
 # 2s-complement style results. (Both clang and gcc agree that it
 # provides these semantics.)
+QEMU_CFLAGS="-Wno-format-truncation $QEMU_CFLALGS"
 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"