* [Patch] Use memcpy instead of strncpy in nscd/nscd.h to fix build problem with ToT GCC
@ 2017-12-12 20:57 Steve Ellcey
2017-12-12 21:26 ` Joseph Myers
2017-12-12 21:29 ` Ramana Radhakrishnan
0 siblings, 2 replies; 3+ messages in thread
From: Steve Ellcey @ 2017-12-12 20:57 UTC (permalink / raw)
To: libc-alpha
The latest ToT GCC is warning about the use of strncpy in nscd/nscd.h.
The strncpy is intentionally truncating a string so the warning is not
really useful in this instance.  Joseph suggested changing it to
a memcpy and that seems to work fine.  I built glibc with ToT GCC
using this patch and ran the glibc test with no regressions on aarch64.
OK to checkin?
Steve Ellcey
sellcey@cavium.com
2017-12-12  Steve Ellcey  <sellcey@cavium.com>
* nscd/nscd.h (init_traced_file): Change strncpy to memcpy.
diff --git a/nscd/nscd.h b/nscd/nscd.h
index c6b0a3c..edcb5b6 100644
--- a/nscd/nscd.h
+++ b/nscd/nscd.h
@@ -108,7 +108,7 @@ init_traced_file(struct traced_file *file, const char *fname, int crinit)
        size_t len = (size_t)(dname - fname);
        if (len > sizeof (file->dname))
  abort ();
-Â Â Â Â Â Â Â strncpy (file->dname, file->fname, len);
+Â Â Â Â Â Â Â memcpy (file->dname, file->fname, len);
        file->dname[len] = '\0';
      }
    /* The basename is the name just after the last forward slash.  */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] Use memcpy instead of strncpy in nscd/nscd.h to fix build problem with ToT GCC
2017-12-12 20:57 [Patch] Use memcpy instead of strncpy in nscd/nscd.h to fix build problem with ToT GCC Steve Ellcey
@ 2017-12-12 21:26 ` Joseph Myers
2017-12-12 21:29 ` Ramana Radhakrishnan
1 sibling, 0 replies; 3+ messages in thread
From: Joseph Myers @ 2017-12-12 21:26 UTC (permalink / raw)
To: Steve Ellcey; +Cc: libc-alpha
[-- Attachment #1: Type: text/plain, Size: 478 bytes --]
On Tue, 12 Dec 2017, Steve Ellcey wrote:
> The latest ToT GCC is warning about the use of strncpy in nscd/nscd.h.
> The strncpy is intentionally truncating a string so the warning is not
> really useful in this instance.  Joseph suggested changing it to
> a memcpy and that seems to work fine.  I built glibc with ToT GCC
> using this patch and ran the glibc test with no regressions on aarch64.
>
> OK to checkin?
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] Use memcpy instead of strncpy in nscd/nscd.h to fix build problem with ToT GCC
2017-12-12 20:57 [Patch] Use memcpy instead of strncpy in nscd/nscd.h to fix build problem with ToT GCC Steve Ellcey
2017-12-12 21:26 ` Joseph Myers
@ 2017-12-12 21:29 ` Ramana Radhakrishnan
1 sibling, 0 replies; 3+ messages in thread
From: Ramana Radhakrishnan @ 2017-12-12 21:29 UTC (permalink / raw)
To: sellcey; +Cc: libc-alpha
On Tue, Dec 12, 2017 at 8:57 PM, Steve Ellcey <sellcey@cavium.com> wrote:
> The latest ToT GCC is warning about the use of strncpy in nscd/nscd.h.
> The strncpy is intentionally truncating a string so the warning is not
> really useful in this instance. Joseph suggested changing it to
> a memcpy and that seems to work fine. I built glibc with ToT GCC
> using this patch and ran the glibc test with no regressions on aarch64.
>
> OK to checkin?
>
> Steve Ellcey
> sellcey@cavium.com
>
>
> 2017-12-12 Steve Ellcey <sellcey@cavium.com>
>
> * nscd/nscd.h (init_traced_file): Change strncpy to memcpy.
>
>
> diff --git a/nscd/nscd.h b/nscd/nscd.h
> index c6b0a3c..edcb5b6 100644
> --- a/nscd/nscd.h
> +++ b/nscd/nscd.h
> @@ -108,7 +108,7 @@ init_traced_file(struct traced_file *file, const char *fname, int crinit)
> size_t len = (size_t)(dname - fname);
> if (len > sizeof (file->dname))
> abort ();
> - strncpy (file->dname, file->fname, len);
> + memcpy (file->dname, file->fname, len);
> file->dname[len] = '\0';
> }
> /* The basename is the name just after the last forward slash. */
Looks good to me FWIW.
Ramana
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-12 21:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-12 20:57 [Patch] Use memcpy instead of strncpy in nscd/nscd.h to fix build problem with ToT GCC Steve Ellcey
2017-12-12 21:26 ` Joseph Myers
2017-12-12 21:29 ` Ramana Radhakrishnan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).