[PATCH v4 05/13] sim/erc32: Fix a few compiler warnings

Jiri Gaisler
2015-03-17T21:03:08Z

* func.c: Minor edits to remove compiler warnings.
* func.c, sis.h (exec_cmd): make second argument const char.
* func.c, sis.h (bfd_load): make argument const char.
---
sim/erc32/func.c | 16 ++++++++--------
sim/erc32/sis.h | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/sim/erc32/func.c b/sim/erc32/func.c
index 122ce64..0dcdf93 100644
--- a/sim/erc32/func.c
+++ b/sim/erc32/func.c
@@ -378,21 +378,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++) {
@@ -609,6 +608,8 @@ exec_cmd(sregs, cmd)
} else
printf("syntax error\n");
}
+ if (cmdsave2 != NULL)
+ free(cmdsave2);
if (cmdsave != NULL)
free(cmdsave);
return (stat);
@@ -1048,8 +1049,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 */
--
1.9.1