On 23/04/18 16:42, Bruce Rogers wrote:
Using gcc8 with the [-Werror=stringop-truncation] option, the following
error is emitted:
util/elf2efi.c:494:2: error: 'strncpy' specified bound 8 equals destination
size [-Werror=stringop-truncation]
strncpy ( ( char * ) new->hdr.Name, name, sizeof ( new->hdr.Name ) );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Specify one less than sizeof the target buffer to avoid this diagnostic.
Since the target buffer is pre-zeroed, the string will be NUL-terminated.
This is a fixed-length string field that is not supposed to be
NUL-terminated. The use of strncpy() here is deliberate in order to be
able to completely fill the field.
Is there a (clean) way to indicate to gcc to ignore this false positive
warning?
Thanks,
Michael
_______________________________________________
ipxe-devel mailing list
ipxe-devel@lists.ipxe.org
https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel