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: [obv] Fix unused-but-set-variable error [Re: [OB] Fix linux-low.c build error]


> This reminds me that I committed a similar patch some days ago.  Here is a
> patch to revert.
> 
> -- 
> Yao (??????) 
> 
> 	* tracepoint.c (gdb_ust_thread): Put an empty if clause for write.
> 
> 	Revert:
> 	2011-12-14  Yao Qi  <yao@codesourcery.com>
> 	* tracepoint.c (gdb_ust_thread): Don't ignore return value
> 	of write.

Thanks! This begs the question, though: Why is it OK to ignore
the error?

I am looking at the code and, not knowing much about tracepoints, I don't
understand well the prupose of gdb_ust_thread (hint: No function
description). As far as I can tell, the write is simply writing the byte
that was read from the connection back to it. What will happen if
we fail to write, and should the user be warned, for instance?

IIRC, in the previous case, we were simply writing to stderr, I think,
and there wasn't much else we could do if that failed...

> Index: gdb/gdbserver/tracepoint.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbserver/tracepoint.c,v
> retrieving revision 1.38
> diff -u -r1.38 tracepoint.c
> --- gdb/gdbserver/tracepoint.c	15 Dec 2011 12:40:03 -0000	1.38
> +++ gdb/gdbserver/tracepoint.c	19 Dec 2011 06:17:49 -0000
> @@ -8122,8 +8122,8 @@
>  		strcpy (cmd_buf, "");
>  	    }
>  
> -	  /* Fix compiler's warning: ignoring return value of 'write'.  */
> -	  ret = write (fd, buf, 1);
> +	  if (write (fd, buf, 1) < 0)
> +	    /* Errors ignored.  */;
>  	  close (fd);
>  	}
>      }

-- 
Joel


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