aboutsummaryrefslogtreecommitdiff
path: root/gcc/genmodes.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-04-19 13:51:17 +0000
committerJim Meyering <meyering@gcc.gnu.org>2012-04-19 13:51:17 +0000
commit75be0217a8b024cc146748db6894ff9e060d7ac9 (patch)
tree1ba4033c565f62c67056f57f928c6283b1ab75f0 /gcc/genmodes.c
parentf68c04877cba9e6f2b77cfb8ba564e37c4d8a254 (diff)
downloadgcc-75be0217a8b024cc146748db6894ff9e060d7ac9.zip
gcc-75be0217a8b024cc146748db6894ff9e060d7ac9.tar.gz
gcc-75be0217a8b024cc146748db6894ff9e060d7ac9.tar.bz2
genmodes: remove misleading use of strncpy
* genmodes.c (make_complex_modes): Avoid unnecessary use of strncpy. We verified above that the string(including trailing NUL) fits in buf, so just use memcpy. From-SVN: r186596
Diffstat (limited to 'gcc/genmodes.c')
-rw-r--r--gcc/genmodes.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/genmodes.c b/gcc/genmodes.c
index 8b6f5bc..6bbeb6f 100644
--- a/gcc/genmodes.c
+++ b/gcc/genmodes.c
@@ -1,5 +1,5 @@
/* Generate the machine mode enumeration and associated tables.
- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 2012
Free Software Foundation, Inc.
This file is part of GCC.
@@ -435,11 +435,14 @@ make_complex_modes (enum mode_class cl,
for (m = modes[cl]; m; m = m->next)
{
+ size_t m_len;
+
/* Skip BImode. FIXME: BImode probably shouldn't be MODE_INT. */
if (m->precision == 1)
continue;
- if (strlen (m->name) >= sizeof buf)
+ m_len = strlen (m->name);
+ if (m_len >= sizeof buf)
{
error ("%s:%d:mode name \"%s\" is too long",
m->file, m->line, m->name);
@@ -452,7 +455,8 @@ make_complex_modes (enum mode_class cl,
if (cl == MODE_FLOAT)
{
char *p, *q = 0;
- strncpy (buf, m->name, sizeof buf);
+ /* We verified above that m->name+NUL fits in buf. */
+ memcpy (buf, m->name, m_len + 1);
p = strchr (buf, 'F');
if (p == 0)
q = strchr (buf, 'D');