mirror of git://gcc.gnu.org/git/gcc.git
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
This commit is contained in:
parent
f68c04877c
commit
75be0217a8
|
@ -1,3 +1,10 @@
|
||||||
|
2012-04-19 Jim Meyering <meyering@redhat.com>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
2012-04-19 Richard Guenther <rguenther@suse.de>
|
2012-04-19 Richard Guenther <rguenther@suse.de>
|
||||||
|
|
||||||
* symtab.c (dump_symtab_base): Use TREE_STRING_POINTER
|
* symtab.c (dump_symtab_base): Use TREE_STRING_POINTER
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Generate the machine mode enumeration and associated tables.
|
/* 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.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GCC.
|
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)
|
for (m = modes[cl]; m; m = m->next)
|
||||||
{
|
{
|
||||||
|
size_t m_len;
|
||||||
|
|
||||||
/* Skip BImode. FIXME: BImode probably shouldn't be MODE_INT. */
|
/* Skip BImode. FIXME: BImode probably shouldn't be MODE_INT. */
|
||||||
if (m->precision == 1)
|
if (m->precision == 1)
|
||||||
continue;
|
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",
|
error ("%s:%d:mode name \"%s\" is too long",
|
||||||
m->file, m->line, m->name);
|
m->file, m->line, m->name);
|
||||||
|
@ -452,7 +455,8 @@ make_complex_modes (enum mode_class cl,
|
||||||
if (cl == MODE_FLOAT)
|
if (cl == MODE_FLOAT)
|
||||||
{
|
{
|
||||||
char *p, *q = 0;
|
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');
|
p = strchr (buf, 'F');
|
||||||
if (p == 0)
|
if (p == 0)
|
||||||
q = strchr (buf, 'D');
|
q = strchr (buf, 'D');
|
||||||
|
|
Loading…
Reference in New Issue