[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [PATCH v1 5/5] linux-user/elfload: Fix GCC 9 build wa
From: |
Laurent Vivier |
Subject: |
Re: [Qemu-trivial] [PATCH v1 5/5] linux-user/elfload: Fix GCC 9 build warnings |
Date: |
Tue, 30 Apr 2019 23:07:56 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
Le 30/04/2019 à 23:01, Alistair Francis a écrit :
> On Tue, Apr 30, 2019 at 1:36 PM Laurent Vivier <address@hidden> wrote:
>>
>> Le 30/04/2019 à 22:09, Alistair Francis a écrit :
>>> Fix this warning when building with GCC9 on Fedora 30:
>>> In function ‘strncpy’,
>>> inlined from ‘fill_psinfo’ at
>>> /home/alistair/qemu/linux-user/elfload.c:3208:12,
>>> inlined from ‘fill_note_info’ at
>>> /home/alistair/qemu/linux-user/elfload.c:3390:5,
>>> inlined from ‘elf_core_dump’ at
>>> /home/alistair/qemu/linux-user/elfload.c:3539:9:
>>> /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’
>>> specified bound 16 equals destination size [-Werror=stringop-truncation]
>>> 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos
>>> (__dest));
>>> |
>>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> Signed-off-by: Alistair Francis <address@hidden>
>>> ---
>>> linux-user/elfload.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
>>> index c1a26021f8..cbb7fc10fa 100644
>>> --- a/linux-user/elfload.c
>>> +++ b/linux-user/elfload.c
>>> @@ -3206,7 +3206,7 @@ static int fill_psinfo(struct target_elf_prpsinfo
>>> *psinfo, const TaskState *ts)
>>
>> /*
>> * Using strncpy here is fine: at max-length,
>>> * this field is not NUL-terminated.
>>> */> (void) strncpy(psinfo->pr_fname, base_filename,
>>> - sizeof(psinfo->pr_fname));
>>> + sizeof(psinfo->pr_fname) - 1);
>>
>> Read the comment above :)
>
> GCC can't read the comment though. The only other option I can think
> of is using a pragma, which I avoided using unless I had to. Would you
> prefer a pragma here? Or do you have a better solution?
>
perhaps:
memcpy(psinfo->pr_fname, base_filename, MIN(strlen(base_filename) + 1,
sizeof(psinfo->pr_fname));
?
Thanks,
Laurent
- Re: [Qemu-trivial] [PATCH v1 2/5] hw/usb/hcd-xhci: Fix GCC 9 build warning, (continued)
[Qemu-trivial] [PATCH v1 3/5] hw/usb/dev-mtp: Fix GCC 9 build warning, Alistair Francis, 2019/04/30
[Qemu-trivial] [PATCH v1 1/5] util/qemu-sockets: Fix GCC 9 build warnings, Alistair Francis, 2019/04/30