From: Tsung-en Hsiao <tsn@cs.nctu.edu.tw>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Fwd: [BUG] Failed to compile using gcc7.1
Date: Mon, 12 Jun 2017 03:08:22 +0800 [thread overview]
Message-ID: <CAPhXLnuNAqwQHdns2Sxv4UuFz9WhGH1ZM4E4TN87e31cDpZ7gQ@mail.gmail.com> (raw)
In-Reply-To: <CAPhXLnv2g_80gi1o6p-QUbKJQ5m+6gkLDN8TWtE-B=70uacDEw@mail.gmail.com>
Hi all,
I encountered the same problem on gcc 7.1.1 and found Qu's mail in
this list from google search.
Temporarily fix it by specifying the string length in snprintf
directive. Hope this is helpful to other people encountered the same
problem.
@@ -1,9 +1,7 @@
---
--- a/block/blkdebug.c
- "blkdebug:%s:%s", s->config_file ?: "",
--- a/block/blkverify.c
- "blkverify:%s:%s",
--- a/hw/usb/bus.c
- snprintf(downstream->path, sizeof(downstream->path), "%s.%d",
- snprintf(downstream->path, sizeof(downstream->path), "%d", portnr);
--
+++ b/block/blkdebug.c
+ "blkdebug:%.2037s:%.2037s", s->config_file ?: "",
+++ b/block/blkverify.c
+ "blkverify:%.2038s:%.2038s",
+++ b/hw/usb/bus.c
+ snprintf(downstream->path, sizeof(downstream->path), "%.12s.%d",
+ snprintf(downstream->path, sizeof(downstream->path), "%.12d", portnr);
Tsung-en Hsiao
> Qu Wenruo Wrote:
>
> Hi all,
>
> After upgrading gcc from 6.3.1 to 7.1.1, qemu can't be compiled with gcc.
>
> The error is:
>
> ------
> CC block/blkdebug.o
> block/blkdebug.c: In function 'blkdebug_refresh_filename':
>
> block/blkdebug.c:693:31: error: '%s' directive output may be truncated writing up to 4095 bytes into a region of size 4086 [-Werror=format-truncation=]
>
> "blkdebug:%s:%s", s->config_file ?: "",
> ^~
> In file included from /usr/include/stdio.h:939:0,
> from /home/adam/qemu/include/qemu/osdep.h:68,
> from block/blkdebug.c:25:
>
> /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output 11 or more bytes (assuming 4106) into a destination of size 4096
>
> 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/adam/qemu/rules.mak:69: block/blkdebug.o] Error 1
> ------
>
> It seems that gcc 7 is introducing more restrict check for printf.
>
> If using clang, although there are some extra warning, it can at least pass the compile.
>
> Thanks,
> Qu
next parent reply other threads:[~2017-06-11 19:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAPhXLnv2g_80gi1o6p-QUbKJQ5m+6gkLDN8TWtE-B=70uacDEw@mail.gmail.com>
2017-06-11 19:08 ` Tsung-en Hsiao [this message]
2017-06-12 3:19 ` [Qemu-devel] Fwd: [BUG] Failed to compile using gcc7.1 Philippe Mathieu-Daudé
2017-06-12 14:16 ` Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPhXLnuNAqwQHdns2Sxv4UuFz9WhGH1ZM4E4TN87e31cDpZ7gQ@mail.gmail.com \
--to=tsn@cs.nctu.edu.tw \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).