This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Silence gcc-8 warnings


Hi,

On Tue, 24 Apr 2018, Alan Modra wrote:

> > The elf-linux-core.h header is regarded as system header with the #line 
> > directives, and that disables the warning.
> 
> Horrible.

I'm not claiming otherwise :-)

> #include <string.h>
> #define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
> 
> Remove the #define and there's no warning!

Probably not the intent of the warning, which should depend on the place 
of the original call not on the place of some intermediate defines.

> 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.


Ciao,
Michael.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]