This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: New Tot Build problem with Tot GCC (strncpy warnings)
- From: Steve Ellcey <sellcey at cavium dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Tue, 12 Dec 2017 10:29:40 -0800
- Subject: Re: New Tot Build problem with Tot GCC (strncpy warnings)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Steve dot Ellcey at cavium dot com;
- References: <1513100610.23303.49.camel@cavium.com> <alpine.DEB.2.20.1712121823210.16954@digraph.polyomino.org.uk>
- Reply-to: sellcey at cavium dot com
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On Tue, 2017-12-12 at 18:24 +0000, Joseph Myers wrote:
>
> > 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.
That sounds right. I will change strncpy to memcpy in my tree and see
if the build works.
Steve Ellcey