WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH]: gdbsx: Check return of write()

To: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH]: gdbsx: Check return of write()
From: Bruce Edge <bruce.edge@xxxxxxxxx>
Date: Tue, 2 Nov 2010 16:29:17 -0700
Cc: Olaf Hering <olaf@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Delivery-date: Tue, 02 Nov 2010 16:30:07 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=hl0uYJh0yUCXuprG7L3NlTyXyIBx7aNrTWazuytpa1E=; b=vpMEazETS3o6Bl3c6qPumA28Kc4sAYKBlS3t6pRdXZhulaW2mV/udHEQeTyPaK1siu ML8AWYRHIdEZtdt1ZT7A6SYWKxB5jP4+S2HvEvfEbxbCAjn807zflwje0x5WFGGjVjqF JCydPhMFMh9DBn38g+dHXTO0C0HGI8G/sFJG0=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=bxEtLh5RMhjSpChWSeU4MULC+S2zsOpjBIH10JguZ5KGl6ANDwQIt4kvj++QlovqSk u0OLv1THyQGI+GL6mWrO3JtBAP4bRzrJpDQI3Q+OyU6Np/T1x8rTn9Ux8Mc88JJVP1KM N8aES071mez8m3yAGRwUTWQJBxrmxMbnM8wKY=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1288714297.23619.59.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20101102103414.GA13749@xxxxxxxxx> <1288714297.23619.59.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Tue, Nov 2, 2010 at 9:11 AM, Gianni Tedesco <gianni.tedesco@xxxxxxxxxx> wrote:
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 <gianni.tedesco@xxxxxxxxxx>

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");


Confirming the same problem:

o-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD -MF .gx_local.o.d  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -Werror -Wmissing-prototypes  -c -o gx_local.o gx_local.c
cc1: warnings being treated as errors
gx_comm.c: In function ‘gx_getpkt’:
gx_comm.c:230: error: ignoring return value of ‘write’, declared with attribute warn_unused_result
gx_comm.c:236: error: ignoring return value of ‘write’, declared with attribute warn_unused_result

%> gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3

-Bruce
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel