From 510d27512cb053e8a9f8c622a5f86840be8c21ac Mon Sep 17 00:00:00 2001 From: Jiri Gaisler Date: Tue, 17 Mar 2015 22:02:42 +0100 Subject: sim/erc32: Fix a few compiler warnings --- sim/erc32/ChangeLog | 8 ++++++++ sim/erc32/func.c | 16 ++++++++-------- sim/erc32/sis.h | 4 ++-- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'sim/erc32') diff --git a/sim/erc32/ChangeLog b/sim/erc32/ChangeLog index 1150e1c..35f0703 100644 --- a/sim/erc32/ChangeLog +++ b/sim/erc32/ChangeLog @@ -1,5 +1,13 @@ 2015-03-28 Jiri Gaisler + * 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 + * erc32.c (memory_iread): New function to fetch instructions. (memory_read): Print message in verbose mode. * interf.c (run_sim): Use memory_iread. diff --git a/sim/erc32/func.c b/sim/erc32/func.c index cef66ed..479c5ee 100644 --- a/sim/erc32/func.c +++ b/sim/erc32/func.c @@ -377,21 +377,20 @@ limcalc (freq) } 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++) { @@ -608,6 +607,8 @@ exec_cmd(sregs, cmd) } else printf("syntax error\n"); } + if (cmdsave2 != NULL) + free(cmdsave2); if (cmdsave != NULL) free(cmdsave); return stat; @@ -1035,8 +1036,7 @@ sys_halt() #define LOAD_ADDRESS 0 int -bfd_load(fname) - char *fname; +bfd_load (const char *fname) { asection *section; bfd *pbfd; diff --git a/sim/erc32/sis.h b/sim/erc32/sis.h index d21bf49..ae39ad1 100644 --- a/sim/erc32/sis.h +++ b/sim/erc32/sis.h @@ -184,7 +184,7 @@ extern struct pstate sregs; 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); @@ -202,7 +202,7 @@ extern int check_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 */ -- cgit v1.1