This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]