From: Thomas Huth <thuth@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
David Hildenbrand <david@redhat.com>,
Igor Mitsyanko <i.mitsyanko@gmail.com>,
Cornelia Huck <cohuck@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
qemu-devel <qemu-devel@nongnu.org>,
Beniamino Galvani <b.galvani@gmail.com>,
"open list:S390 SCLP-backed..." <qemu-s390x@nongnu.org>,
qemu-arm <qemu-arm@nongnu.org>,
Antony Pavlov <antonynpavlov@gmail.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [PATCH 5/5] s390x/tcg: fix format-truncation warning
Date: Tue, 29 Mar 2022 16:44:49 +0200 [thread overview]
Message-ID: <5c250438-83c7-679b-edab-9704823df474@redhat.com> (raw)
In-Reply-To: <CAMxuvaxHgVy-JA+XzAKJ4cjGYefpxyE_fmMLRqzPQPjVQKV8yg@mail.gmail.com>
On 28/03/2022 12.22, Marc-André Lureau wrote:
> Hi
>
> On Mon, Mar 28, 2022 at 12:59 PM Thomas Huth <thuth@redhat.com> wrote:
>>
>> On 28/03/2022 10.47, marcandre.lureau@redhat.com wrote:
>>> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>>>
>>> ../target/s390x/tcg/translate.c: In function ‘s390x_translate_init’:
>>> ../target/s390x/tcg/translate.c:224:64: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]
>>> 224 | snprintf(cpu_reg_names[i], sizeof(cpu_reg_names[0]), "r%d", i);
>>> | ^~
>>>
>>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>> ---
>>> target/s390x/tcg/translate.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
>>> index 5acfc0ff9b4e..a082342a0424 100644
>>> --- a/target/s390x/tcg/translate.c
>>> +++ b/target/s390x/tcg/translate.c
>>> @@ -199,7 +199,7 @@ static TCGv_i64 regs[16];
>>>
>>> void s390x_translate_init(void)
>>> {
>>> - int i;
>>> + size_t i;
>>>
>>> psw_addr = tcg_global_mem_new_i64(cpu_env,
>>> offsetof(CPUS390XState, psw.addr),
>>> @@ -221,7 +221,7 @@ void s390x_translate_init(void)
>>> "cc_vr");
>>>
>>> for (i = 0; i < 16; i++) {
>>> - snprintf(cpu_reg_names[i], sizeof(cpu_reg_names[0]), "r%d", i);
>>> + snprintf(cpu_reg_names[i], sizeof(cpu_reg_names[0]), "r%zu", i);
>>
>> The compiler is *really* too stupid to see that i is in the range between 0
>> and 16 here??? ... that rather sounds like a compiler bug to me than
>> something that we should work-around in the QEMU source code. Considering
>> that you're using a x.0 release of GCC, please file a bug against GCC
>> instead. If they refuse to fix it for GCC 12.1 or later, we can revisit this
>> patch, but currently, I really think this should be fixed in GCC instead.
>>
>
> I opened: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105080
Thanks! Looks like it will be fixed in the final release of GCC 12, so I
think we can definitely drop this QEMU patch here.
Thomas
next prev parent reply other threads:[~2022-03-29 14:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 8:47 [PATCH 0/5] Compilation fixes for 7.0 marcandre.lureau
2022-03-28 8:47 ` [PATCH 1/5] trace: fix compilation with lttng-ust >= 2.13 marcandre.lureau
2022-03-30 12:06 ` Stefan Hajnoczi
2022-03-31 15:45 ` Marc-André Lureau
2022-03-31 16:08 ` Stefan Hajnoczi
2022-03-28 8:47 ` [PATCH 2/5] arm/digic: fix format-truncation warning marcandre.lureau
2022-03-28 9:12 ` Peter Maydell
2022-03-28 9:21 ` Thomas Huth
2022-03-28 8:47 ` [PATCH 3/5] arm/allwinner-a10: fix format-overflow warning marcandre.lureau
2022-03-28 9:13 ` Peter Maydell
2022-03-28 8:47 ` [PATCH 4/5] intc/exynos4210_gic: " marcandre.lureau
2022-03-28 9:15 ` Peter Maydell
2022-03-29 17:07 ` Philippe Mathieu-Daudé
2022-03-29 17:23 ` Peter Maydell
2022-03-28 8:47 ` [PATCH 5/5] s390x/tcg: fix format-truncation warning marcandre.lureau
2022-03-28 8:58 ` Thomas Huth
2022-03-28 10:22 ` Marc-André Lureau
2022-03-28 10:57 ` Thomas Huth
2022-03-29 14:44 ` Thomas Huth [this message]
2022-03-28 9:01 ` David Hildenbrand
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=5c250438-83c7-679b-edab-9704823df474@redhat.com \
--to=thuth@redhat.com \
--cc=antonynpavlov@gmail.com \
--cc=b.galvani@gmail.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=i.mitsyanko@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
/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).