[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 5/5] s390x/tcg: fix format-truncation warning
From: |
David Hildenbrand |
Subject: |
Re: [PATCH 5/5] s390x/tcg: fix format-truncation warning |
Date: |
Mon, 28 Mar 2022 11:01:06 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 |
On 28.03.22 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);
> regs[i] = tcg_global_mem_new(cpu_env,
> offsetof(CPUS390XState, regs[i]),
> cpu_reg_names[i]);
Ehm, what?
How can "r0" ... "r15" ever consume more than 3 bytes + "\0"?
--
Thanks,
David / dhildenb
- Re: [PATCH 2/5] arm/digic: fix format-truncation warning, (continued)