mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 14:49:38 +08:00
sim: constify arg to sim_do_command
It is rare for people to want to modify the cmd arg. In general, they really shouldn't be, but a few still do. For those who misbehave, dupe the string locally so they can bang on it.
This commit is contained in:
@ -1,3 +1,8 @@
|
||||
2014-03-10 Mike Frysinger <vapier@gentoo.org>
|
||||
|
||||
* gdb-if.c (sim_do_command): Add const to cmd. Move args
|
||||
to top and add const. Call strdup on cmd and free at end.
|
||||
|
||||
2014-03-05 Mike Frysinger <vapier@gentoo.org>
|
||||
|
||||
* gdb-if.c (sim_load): Add const to prog.
|
||||
|
@ -650,11 +650,12 @@ sim_stop_reason (SIM_DESC sd, enum sim_stop *reason_p, int *sigrc_p)
|
||||
}
|
||||
|
||||
void
|
||||
sim_do_command (SIM_DESC sd, char *cmd)
|
||||
sim_do_command (SIM_DESC sd, const char *cmd)
|
||||
{
|
||||
check_desc (sd);
|
||||
const char *args;
|
||||
char *p = strdup (cmd);
|
||||
|
||||
char *p = cmd;
|
||||
check_desc (sd);
|
||||
|
||||
/* Skip leading whitespace. */
|
||||
while (isspace (*p))
|
||||
@ -667,7 +668,6 @@ sim_do_command (SIM_DESC sd, char *cmd)
|
||||
|
||||
/* Null-terminate the command word, and record the start of any
|
||||
further arguments. */
|
||||
char *args;
|
||||
if (*p)
|
||||
{
|
||||
*p = '\0';
|
||||
@ -701,6 +701,8 @@ sim_do_command (SIM_DESC sd, char *cmd)
|
||||
else
|
||||
printf ("The 'sim' command expects either 'trace' or 'verbose'"
|
||||
" as a subcommand.\n");
|
||||
|
||||
free (p);
|
||||
}
|
||||
|
||||
char **
|
||||
|
Reference in New Issue
Block a user