[prev in list] [next in list] [prev in thread] [next in thread]
List: binutils
Subject: Re: Silence gcc-8 warnings
From: Franz Sirl <Franz.Sirl-kernel () lauterbach ! com>
Date: 2018-04-24 12:34:12
Message-ID: 19cd2f38-075e-4271-45ea-19a61a13191d () lauterbach ! com
[Download RAW message or body]
Am 2018-04-24 um 14:07 schrieb Michael Matz:> Hi,
>
> On Tue, 24 Apr 2018, Alan Modra wrote:
>
>> No, it is not a bug. We have internal and external structs, and a
>> field in the external struct that does not need to be NULL
>> terminated.
>
> Ah, that's the crucial point (plus the zero termination for
convenience of
> the internal one). Well, so the warning is correct still (according to
> its intent, which may or may not be ill advised), but of course doesn't
> take that into account.
>
>> What's more, we do want strncpy behaviour rather than memcpy, since for
>> defensive programming we don't want to copy possibly uninitialized data
>> past a string terminator in the internal representation, and do want to
>> fill the external representation with zeros.
>
> Yeah, understood.
Hi,
unfortunately it's too late for GCC-8, but for GCC-9 I intend to open an
enhancement request to split -Wstringop-truncation (and a similar case
for -Wsizeof-pointer-memaccess).
Something like -Wstringop-truncation will not warn for strncpy's
documented (!) natural usage to copy to a fixed size record (non-null
terminated char array), but -Wstringop-truncation-strict
(-Wstringop-truncation-secure?) will warn.
Franz Sirl
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic