[PATCH v3 02/14] sim/erc32: Removed type mismatch compiler warnings

Mike Frysinger vapier@gentoo.org
Mon Mar 2 01:04:00 GMT 2015


On 01 Mar 2015 22:10, Jiri Gaisler wrote:
>      while (!feof(fp)) {
> -	lbuf[0] = 0;
> -	fgets(lbuf, 1023, fp);
> -	if ((strlen(lbuf) > 0) && (lbuf[strlen(lbuf) - 1] == '\n'))
> +	if (getline(&lbuf, &len, fp) == -1)
> +	    break;

do you still need the feof check ?  getline will do that for you:
	while (getline(&lbuf, &len, fp) != -1)

> +	if ((strlen(lbuf) > 0) && (lbuf[strlen(lbuf) - 1] == '\n')) {
>  	    lbuf[strlen(lbuf) - 1] = 0;

is gcc smart enough to cache that strlen call ?  might be better to do it 
yourself:
	size_t slen = strlen(lbuf);
	if (slen && lbuf[slen - 1] == '\n')
	  lbuf[slen - 1] = 0;

> @@ -383,7 +387,7 @@ exec_cmd(sregs, cmd)
>  {
>      char           *cmd1, *cmd2;
>      int32           stat;
> -    uint32          len, i, clen, j;
> +    uint32          len, i, clen, j, tmp;
>      static uint32   daddr = 0;
>      char           *cmdsave;
>  

do you still need |tmp| now that you changed how the system() warning is
silenced ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20150302/4ece9815/attachment.sig>


More information about the Gdb-patches mailing list