use xstrdup and friends more
gas/ChangeLog: 2016-03-29 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * config/tc-hppa.c (pa_space): Use xstrdup where appropriate. (pa_subspace): Likewise. (create_new_space): Likewise. (create_new_subspace): Likewise. * config/tc-mips.c (mips_lookup_insn): Likewise. * config/tc-tic4x.c (tic4x_asg): Likewise. * config/tc-tic54x.c (tic54x_eval): Likewise. (stag_add_field): Likewise. (tic54x_usect): Likewise. (tic54x_clink): Likewise. (tic54x_set_default_include): Likewise. (tic54x_include): Likewise. (tic54x_message): Likewise. (tic54x_sblock): Likewise. (tic54x_var): Likewise. (subsym_ismember): Likewise. (subsym_substitute): Likewise. * config/tc-xtensa.c (xg_replace_opname): Likewise. (xg_translate_sysreg_op): Likewise. (xg_translate_idioms): Likewise. (md_assemble): Likewise. (cache_literal_section): Likewise.
This commit is contained in:
parent
49efcf2ab9
commit
4ec9d7d564
@ -7300,8 +7300,7 @@ pa_space (int unused ATTRIBUTE_UNUSED)
|
||||
print_errors = 1;
|
||||
input_line_pointer = save_s;
|
||||
c = get_symbol_name (&name);
|
||||
space_name = xmalloc (strlen (name) + 1);
|
||||
strcpy (space_name, name);
|
||||
space_name = xstrdup (name);
|
||||
(void) restore_line_pointer (c);
|
||||
|
||||
sd_chain = pa_parse_space_stmt (space_name, 1);
|
||||
@ -7365,8 +7364,7 @@ pa_subspace (int create_new)
|
||||
else
|
||||
{
|
||||
c = get_symbol_name (&name);
|
||||
ss_name = xmalloc (strlen (name) + 1);
|
||||
strcpy (ss_name, name);
|
||||
ss_name = xstrdup (name);
|
||||
(void) restore_line_pointer (c);
|
||||
|
||||
/* Load default values. */
|
||||
@ -7725,8 +7723,7 @@ create_new_space (char *name,
|
||||
as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
|
||||
name);
|
||||
|
||||
SPACE_NAME (chain_entry) = xmalloc (strlen (name) + 1);
|
||||
strcpy (SPACE_NAME (chain_entry), name);
|
||||
SPACE_NAME (chain_entry) = xstrdup (name);
|
||||
SPACE_DEFINED (chain_entry) = defined;
|
||||
SPACE_USER_DEFINED (chain_entry) = user_defined;
|
||||
SPACE_SPNUM (chain_entry) = spnum;
|
||||
@ -7812,8 +7809,7 @@ create_new_subspace (sd_chain_struct *space,
|
||||
if (!chain_entry)
|
||||
as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name);
|
||||
|
||||
SUBSPACE_NAME (chain_entry) = xmalloc (strlen (name) + 1);
|
||||
strcpy (SUBSPACE_NAME (chain_entry), name);
|
||||
SUBSPACE_NAME (chain_entry) = xstrdup (name);
|
||||
|
||||
/* Initialize subspace_defined. When we hit a .subspace directive
|
||||
we'll set it to 1 which "locks-in" the subspace attributes. */
|
||||
|
@ -13531,9 +13531,7 @@ mips_lookup_insn (struct hash_control *hash, const char *start,
|
||||
struct mips_opcode *insn;
|
||||
|
||||
/* Make a copy of the instruction so that we can fiddle with it. */
|
||||
name = xmalloc (length + 1);
|
||||
memcpy (name, start, length);
|
||||
name[length] = '\0';
|
||||
name = xstrndup (start, length);
|
||||
|
||||
/* Look up the instruction as-is. */
|
||||
insn = (struct mips_opcode *) hash_find (hash, name);
|
||||
|
@ -713,7 +713,6 @@ tic4x_asg (int x ATTRIBUTE_UNUSED)
|
||||
char c;
|
||||
char *name;
|
||||
char *str;
|
||||
char *tmp;
|
||||
|
||||
SKIP_WHITESPACE ();
|
||||
str = input_line_pointer;
|
||||
@ -728,12 +727,8 @@ tic4x_asg (int x ATTRIBUTE_UNUSED)
|
||||
}
|
||||
*input_line_pointer++ = '\0';
|
||||
c = get_symbol_name (&name); /* Get terminator. */
|
||||
tmp = xmalloc (strlen (str) + 1);
|
||||
strcpy (tmp, str);
|
||||
str = tmp;
|
||||
tmp = xmalloc (strlen (name) + 1);
|
||||
strcpy (tmp, name);
|
||||
name = tmp;
|
||||
str = xstrdup (str);
|
||||
name = xstrdup (name);
|
||||
if (hash_find (tic4x_asg_hash, name))
|
||||
hash_replace (tic4x_asg_hash, name, (void *) str);
|
||||
else
|
||||
|
@ -407,8 +407,7 @@ tic54x_eval (int x ATTRIBUTE_UNUSED)
|
||||
return;
|
||||
}
|
||||
c = get_symbol_name (&name); /* Get terminator. */
|
||||
tmp = xmalloc (strlen (name) + 1);
|
||||
name = strcpy (tmp, name);
|
||||
name = xstrdup (name);
|
||||
(void) restore_line_pointer (c);
|
||||
|
||||
if (!ISALPHA (*name))
|
||||
@ -426,8 +425,7 @@ tic54x_eval (int x ATTRIBUTE_UNUSED)
|
||||
But since there's not written rule as to when, don't even bother trying
|
||||
to match their behavior. */
|
||||
sprintf (valuestr, "%d", value);
|
||||
tmp = xmalloc (strlen (valuestr) + 1);
|
||||
strcpy (tmp, valuestr);
|
||||
tmp = xstrdup (valuestr);
|
||||
subsym_create_or_replace (name, tmp);
|
||||
|
||||
demand_empty_rest_of_line ();
|
||||
@ -598,7 +596,7 @@ stag_add_field (struct stag *parent,
|
||||
struct stag_field *sfield = xmalloc (sizeof (struct stag_field));
|
||||
|
||||
memset (sfield, 0, sizeof (*sfield));
|
||||
sfield->name = strcpy (xmalloc (strlen (name) + 1), name);
|
||||
sfield->name = xstrdup (name);
|
||||
sfield->offset = offset;
|
||||
sfield->bitfield_offset = parent->current_bitfield_offset;
|
||||
sfield->stag = stag;
|
||||
@ -1361,8 +1359,7 @@ tic54x_usect (int x ATTRIBUTE_UNUSED)
|
||||
current_subseg = now_subseg; /* Save current subseg. */
|
||||
|
||||
c = get_symbol_name (§ion_name); /* Get terminator. */
|
||||
name = xmalloc (input_line_pointer - section_name + 1);
|
||||
strcpy (name, section_name);
|
||||
name = xstrdup (section_name);
|
||||
c = restore_line_pointer (c);
|
||||
|
||||
if (c == ',')
|
||||
@ -1831,8 +1828,7 @@ tic54x_clink (int ignored ATTRIBUTE_UNUSED)
|
||||
;
|
||||
know (input_line_pointer[-1] == '\"');
|
||||
input_line_pointer[-1] = 0;
|
||||
name = xmalloc (input_line_pointer - section_name + 1);
|
||||
strcpy (name, section_name);
|
||||
name = xstrdup (section_name);
|
||||
|
||||
seg = bfd_get_section_by_name (stdoutput, name);
|
||||
if (seg == NULL)
|
||||
@ -1874,7 +1870,7 @@ tic54x_set_default_include (int dot)
|
||||
unsigned lineno;
|
||||
|
||||
curfile = as_where (&lineno);
|
||||
dir = strcpy (xmalloc (strlen (curfile) + 1), curfile);
|
||||
dir = xstrdup (curfile);
|
||||
tmp = strrchr (dir, '/');
|
||||
}
|
||||
if (tmp != NULL)
|
||||
@ -1931,7 +1927,7 @@ tic54x_include (int ignored ATTRIBUTE_UNUSED)
|
||||
++input_line_pointer;
|
||||
c = *input_line_pointer;
|
||||
*input_line_pointer = '\0';
|
||||
filename = strcpy (xmalloc (strlen (filename) + 1), filename);
|
||||
filename = xstrdup (filename);
|
||||
*input_line_pointer = c;
|
||||
demand_empty_rest_of_line ();
|
||||
}
|
||||
@ -1968,7 +1964,7 @@ tic54x_message (int type)
|
||||
++input_line_pointer;
|
||||
c = *input_line_pointer;
|
||||
*input_line_pointer = 0;
|
||||
msg = strcpy (xmalloc (strlen (msg) + 1), msg);
|
||||
msg = xstrdup (msg);
|
||||
*input_line_pointer = c;
|
||||
}
|
||||
|
||||
@ -2135,8 +2131,7 @@ tic54x_sblock (int ignore ATTRIBUTE_UNUSED)
|
||||
char *section_name;
|
||||
|
||||
c = get_symbol_name (§ion_name);
|
||||
name = xmalloc (strlen (section_name) + 1);
|
||||
strcpy (name, section_name);
|
||||
name = xstrdup (section_name);
|
||||
(void) restore_line_pointer (c);
|
||||
}
|
||||
|
||||
@ -2249,7 +2244,7 @@ tic54x_var (int ignore ATTRIBUTE_UNUSED)
|
||||
}
|
||||
c = get_symbol_name (&name);
|
||||
/* .var symbols start out with a null string. */
|
||||
name = strcpy (xmalloc (strlen (name) + 1), name);
|
||||
name = xstrdup (name);
|
||||
hash_insert (subsym_hash[macro_level], name, empty);
|
||||
c = restore_line_pointer (c);
|
||||
if (c == ',')
|
||||
@ -2617,8 +2612,7 @@ subsym_ismember (char *sym, char *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ptr = elem = xmalloc (strlen (listv) + 1);
|
||||
strcpy (elem, listv);
|
||||
ptr = elem = xstrdup (listv);
|
||||
while (*ptr && *ptr != ',')
|
||||
++ptr;
|
||||
*ptr++ = 0;
|
||||
@ -4411,8 +4405,7 @@ subsym_substitute (char *line, int forced)
|
||||
char *tmp;
|
||||
|
||||
/* Work with a copy of the input line. */
|
||||
replacement = xmalloc (strlen (line) + 1);
|
||||
strcpy (replacement, line);
|
||||
replacement = xstrdup (line);
|
||||
|
||||
ptr = head = replacement;
|
||||
|
||||
@ -4667,8 +4660,7 @@ subsym_substitute (char *line, int forced)
|
||||
kinda indicates that forced substitution is not
|
||||
supposed to be recursive, but I'm not sure. */
|
||||
unsigned beg, len = 1; /* default to a single char */
|
||||
char *newval = strcpy (xmalloc (strlen (value) + 1),
|
||||
value);
|
||||
char *newval = xstrdup (value);
|
||||
|
||||
savedp = input_line_pointer;
|
||||
input_line_pointer = tail + 1;
|
||||
|
@ -2274,8 +2274,7 @@ static void
|
||||
xg_replace_opname (char **popname, const char *newop)
|
||||
{
|
||||
free (*popname);
|
||||
*popname = (char *) xmalloc (strlen (newop) + 1);
|
||||
strcpy (*popname, newop);
|
||||
*popname = xstrdup (newop);
|
||||
}
|
||||
|
||||
|
||||
@ -2370,8 +2369,7 @@ xg_translate_sysreg_op (char **popname, int *pnum_args, char **arg_strings)
|
||||
/* Another special case for "WSR.INTSET".... */
|
||||
if (is_write && !is_user && !strcasecmp ("interrupt", sr_name))
|
||||
sr_name = "intset";
|
||||
new_opname = (char *) xmalloc (strlen (sr_name) + 6);
|
||||
sprintf (new_opname, "%s.%s", *popname, sr_name);
|
||||
new_opname = concat (*popname, ".", sr_name, (char *) NULL);
|
||||
free (*popname);
|
||||
*popname = new_opname;
|
||||
|
||||
@ -2495,8 +2493,7 @@ xg_translate_idioms (char **popname, int *pnum_args, char **arg_strings)
|
||||
if (xg_check_num_args (pnum_args, 2, opname, arg_strings))
|
||||
return -1;
|
||||
xg_replace_opname (popname, (has_underbar ? "_or" : "or"));
|
||||
arg_strings[2] = (char *) xmalloc (strlen (arg_strings[1]) + 1);
|
||||
strcpy (arg_strings[2], arg_strings[1]);
|
||||
arg_strings[2] = xstrdup (arg_strings[1]);
|
||||
*pnum_args = 3;
|
||||
}
|
||||
return 0;
|
||||
@ -2536,12 +2533,9 @@ xg_translate_idioms (char **popname, int *pnum_args, char **arg_strings)
|
||||
if (xg_check_num_args (pnum_args, 0, opname, arg_strings))
|
||||
return -1;
|
||||
xg_replace_opname (popname, (has_underbar ? "_or" : "or"));
|
||||
arg_strings[0] = (char *) xmalloc (3);
|
||||
arg_strings[1] = (char *) xmalloc (3);
|
||||
arg_strings[2] = (char *) xmalloc (3);
|
||||
strcpy (arg_strings[0], "a1");
|
||||
strcpy (arg_strings[1], "a1");
|
||||
strcpy (arg_strings[2], "a1");
|
||||
arg_strings[0] = xstrdup ("a1");
|
||||
arg_strings[1] = xstrdup ("a1");
|
||||
arg_strings[2] = xstrdup ("a1");
|
||||
*pnum_args = 3;
|
||||
}
|
||||
return 0;
|
||||
@ -5501,9 +5495,7 @@ md_assemble (char *str)
|
||||
|
||||
/* Split off the opcode. */
|
||||
opnamelen = strspn (str, "abcdefghijklmnopqrstuvwxyz_/0123456789.");
|
||||
opname = xmalloc (opnamelen + 1);
|
||||
memcpy (opname, str, opnamelen);
|
||||
opname[opnamelen] = '\0';
|
||||
opname = xstrndup (str, opnamelen);
|
||||
|
||||
num_args = tokenize_arguments (arg_strings, str + opnamelen);
|
||||
if (num_args == -1)
|
||||
@ -11559,19 +11551,14 @@ cache_literal_section (bfd_boolean use_abs_literals)
|
||||
base_name = use_abs_literals ? ".lit4" : ".literal";
|
||||
if (group_name)
|
||||
{
|
||||
name = xmalloc (strlen (base_name) + strlen (group_name) + 2);
|
||||
sprintf (name, "%s.%s", base_name, group_name);
|
||||
name = concat (base_name, ".", group_name, (char *) NULL);
|
||||
}
|
||||
else if (strncmp (text_name, ".gnu.linkonce.", linkonce_len) == 0)
|
||||
{
|
||||
suffix = strchr (text_name + linkonce_len, '.');
|
||||
|
||||
name = xmalloc (linkonce_len + strlen (base_name) + 1
|
||||
+ (suffix ? strlen (suffix) : 0));
|
||||
strcpy (name, ".gnu.linkonce");
|
||||
strcat (name, base_name);
|
||||
if (suffix)
|
||||
strcat (name, suffix);
|
||||
name = concat (".gnu.linkonce", base_name, suffix ? suffix : "",
|
||||
(char *) NULL);
|
||||
linkonce = TRUE;
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user