[13/23] sim/erc32: Fix a few compiler warnings

Message ID 1424159099-5148-14-git-send-email-jiri@gaisler.se
State Superseded
Headers

Commit Message

Jiri Gaisler Feb. 17, 2015, 7:44 a.m. UTC
  Minor edits to remove compiler warnings.
---
 sim/erc32/interf.c | 2 +-
 sim/erc32/sis.h    | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
  

Comments

Mike Frysinger Feb. 17, 2015, 11:07 a.m. UTC | #1
On 17 Feb 2015 08:44, Jiri Gaisler wrote:
> 	Minor edits to remove compiler warnings.

if you're really interested in doing this, you could add SIM_AC_OPTION_WARNINGS 
to the erc32/configure.ac script ...

> --- a/sim/erc32/interf.c
> +++ b/sim/erc32/interf.c
> @@ -509,7 +509,7 @@ sim_do_command(sd, cmd)
>       SIM_DESC sd;
>       const char *cmd;
>  {
> -    exec_cmd(&sregs, cmd);
> +    exec_cmd(&sregs, (char *) cmd);
>  }

shouldn't exec_cmd be changed to take a const char * instead ?  looks to me like 
it treats it as constant ... it does a strdup(cmd) and only operates on the 
result.

looking further, seems like it this func really should use buildargv/freeargv 
rather than tokenize things itself ?
-mike
  
Jiri Gaisler Feb. 18, 2015, 4:21 p.m. UTC | #2
On 02/17/2015 12:07 PM, Mike Frysinger wrote:
> On 17 Feb 2015 08:44, Jiri Gaisler wrote:
>> 	Minor edits to remove compiler warnings.
> 
> if you're really interested in doing this, you could add SIM_AC_OPTION_WARNINGS 
> to the erc32/configure.ac script ...
> 
>> --- a/sim/erc32/interf.c
>> +++ b/sim/erc32/interf.c
>> @@ -509,7 +509,7 @@ sim_do_command(sd, cmd)
>>       SIM_DESC sd;
>>       const char *cmd;
>>  {
>> -    exec_cmd(&sregs, cmd);
>> +    exec_cmd(&sregs, (char *) cmd);
>>  }
> 
> shouldn't exec_cmd be changed to take a const char * instead ?  looks to me like 
> it treats it as constant ... it does a strdup(cmd) and only operates on the 
> result.

I am passing cmd to strok() at one place, so const char cannot be used.

> 
> looking further, seems like it this func really should use buildargv/freeargv 
> rather than tokenize things itself ?
> -mike
> 

I will keep this on my soon-todo list. Please bare with it this time ...

Jiri.
  
Mike Frysinger Feb. 18, 2015, 4:51 p.m. UTC | #3
On 18 Feb 2015 17:21, Jiri Gaisler wrote:
> On 02/17/2015 12:07 PM, Mike Frysinger wrote:
> > On 17 Feb 2015 08:44, Jiri Gaisler wrote:
> >> 	Minor edits to remove compiler warnings.
> > 
> > if you're really interested in doing this, you could add SIM_AC_OPTION_WARNINGS 
> > to the erc32/configure.ac script ...
> > 
> >> --- a/sim/erc32/interf.c
> >> +++ b/sim/erc32/interf.c
> >> @@ -509,7 +509,7 @@ sim_do_command(sd, cmd)
> >>       SIM_DESC sd;
> >>       const char *cmd;
> >>  {
> >> -    exec_cmd(&sregs, cmd);
> >> +    exec_cmd(&sregs, (char *) cmd);
> >>  }
> > 
> > shouldn't exec_cmd be changed to take a const char * instead ?  looks to me like 
> > it treats it as constant ... it does a strdup(cmd) and only operates on the 
> > result.
> 
> I am passing cmd to strok() at one place, so const char cannot be used.

ah, i see that now yes.  i'm not sure deploying the cast is correct as the API 
allows for a constant to be passed in at which time this would crash.

> > looking further, seems like it this func really should use buildargv/freeargv 
> > rather than tokenize things itself ?
> 
> I will keep this on my soon-todo list. Please bare with it this time ...

np.  in the meantime, adding a second dupe should allow for minimal code change.
-mike
  

Patch

diff --git a/sim/erc32/interf.c b/sim/erc32/interf.c
index 981aa11..f03f1d5 100644
--- a/sim/erc32/interf.c
+++ b/sim/erc32/interf.c
@@ -509,7 +509,7 @@  sim_do_command(sd, cmd)
      SIM_DESC sd;
      const char *cmd;
 {
-    exec_cmd(&sregs, cmd);
+    exec_cmd(&sregs, (char *) cmd);
 }
 
 char **
diff --git a/sim/erc32/sis.h b/sim/erc32/sis.h
index 604d344..e2bed36 100644
--- a/sim/erc32/sis.h
+++ b/sim/erc32/sis.h
@@ -203,7 +203,6 @@  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 double	get_time (void);
 
 /* exec.c */