+2015-03-28 Jiri Gaisler <jiri@gaisler.se>
+
+ * func.c (exec_cmd): Fix old style prototype. Mark cmd const. Save
+ the command in a new cmdsave2 to avoid modifying.
+ (bfd_load): Fix old style prototype. Mark fname const.
+ * sis.h (exec_cmd): Mark cmd const.
+ (bfd_load): Mark fname const.
+
2015-03-28 Jiri Gaisler <jiri@gaisler.se>
* erc32.c (memory_iread): New function to fetch instructions.
}
return lim;
}
-
+
int
-exec_cmd(sregs, cmd)
- char *cmd;
- struct pstate *sregs;
+exec_cmd(struct pstate *sregs, const char *cmd)
{
char *cmd1, *cmd2;
int32 stat;
uint32 len, i, clen, j;
static uint32 daddr = 0;
- char *cmdsave;
+ char *cmdsave, *cmdsave2 = NULL;
stat = OK;
cmdsave = strdup(cmd);
- if ((cmd1 = strtok(cmd, " \t")) != NULL) {
+ cmdsave2 = strdup (cmd);
+ if ((cmd1 = strtok (cmdsave2, " \t")) != NULL) {
clen = strlen(cmd1);
if (strncmp(cmd1, "bp", clen) == 0) {
for (i = 0; i < sregs->bptnum; i++) {
} else
printf("syntax error\n");
}
+ if (cmdsave2 != NULL)
+ free(cmdsave2);
if (cmdsave != NULL)
free(cmdsave);
return stat;
#define LOAD_ADDRESS 0
int
-bfd_load(fname)
- char *fname;
+bfd_load (const char *fname)
{
asection *section;
bfd *pbfd;
extern void set_regi (struct pstate *sregs, int32 reg,
uint32 rval);
extern void get_regi (struct pstate *sregs, int32 reg, char *buf);
-extern int exec_cmd (struct pstate *sregs, char *cmd);
+extern int exec_cmd (struct pstate *sregs, const char *cmd);
extern void reset_stat (struct pstate *sregs);
extern void show_stat (struct pstate *sregs);
extern void init_bpt (struct pstate *sregs);
extern void reset_all (void);
extern void sys_reset (void);
extern void sys_halt (void);
-extern int bfd_load (char *fname);
+extern int bfd_load (const char *fname);
extern double get_time (void);
/* exec.c */