From: Gianni Tedesco Subject: [PATCH]: gdbsx: Check return of write() Date: Tue, 2 Nov 2010 16:11:37 +0000 Message-ID: <1288714297.23619.59.camel@qabil.uk.xensource.com> References: <20101102103414.GA13749@aepfle.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20101102103414.GA13749@aepfle.de> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Olaf Hering Cc: Ian, "xen-devel@lists.xensource.com" , Jackson List-Id: xen-devel@lists.xenproject.org On Tue, 2010-11-02 at 10:34 +0000, Olaf Hering wrote: > Hello, > > there is a regression between xen-unstable rev 22314 and 22344, > gx_comm.c does not compile anymore due to -Werror, see below. > I think a simpe 'if (write(args..)) perror("write");' will be good enough. > > Olaf FYI: it doesn't look like a regression but perhaps a compiler/library update? ---8<-------------8<--------------8<-------------------- This leads to warn_unused_result checks triggering in some libraries and compilers. Combined with -Werror this breaks the build. Signed-off-by: Gianni Tedesco diff -r ee4d52f0d16a tools/debugger/gdbsx/gx/gx_comm.c --- a/tools/debugger/gdbsx/gx/gx_comm.c Tue Nov 02 07:35:52 2010 +0000 +++ b/tools/debugger/gdbsx/gx/gx_comm.c Tue Nov 02 16:06:43 2010 +0000 @@ -227,13 +227,15 @@ gx_getpkt (char *buf) gxprt("Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n", (c1 << 4) + c2, csum, buf); - write(remote_fd, "-", 1); + if ( write(remote_fd, "-", 1) != 1 ) + perror("write"); } if (gx_remote_dbg) { gxprt("getpkt (\"%s\"); [sending ack] \n", buf); } - write(remote_fd, "+", 1); + if ( write(remote_fd, "+", 1) != 1 ) + perror("write"); if (gx_remote_dbg) { gxprt("[sent ack]\n");