New Tot Build problem with Tot GCC (strncpy warnings)
Joseph Myers
joseph@codesourcery.com
Tue Dec 12 18:24:00 GMT 2017
On Tue, 12 Dec 2017, Steve Ellcey wrote:
> I am not sure if this is due to a GCC change or a glibc change but I am
> still unable to build the ToT glibc with the ToT GCC.  The
> nextafter/nexttoward problem has been fixed, the current errors I get
> are due to strncpy warnings. Â I thought we had fixed these but either
> GCC changed or glibc changed and we have some new ones:
>
> Building glibc on aarch64:
>
> In file included from nss_files/files-init.c:22:
> nss_files/files-init.c: In function â_nss_files_initâ:
> ../nscd/nscd.h:111:8: error: âstrncpyâ output truncated copying 4 bytes
> from a string of length 11 [-Werror=stringop-truncation]
> Â Â Â Â Â Â Â Â strncpy (file->dname, file->fname, len);
> Â Â Â Â Â Â Â Â ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
These look like they should be memcpy. The truncation is intended (it's
copying a directory name without the trailing '/' and filename in the
source string), but since the exact amount to copy is known at that point,
memcpy suffices to express the intent and should avoid the warning.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list