Skip to contentSkip to conversation

new compile error in gx_comm.c in xen-unstable

PATCH In review Olaf Hering 4 participants 7 messages Nov 2, 2010 – Nov 3, 2010

lore
Share & tools
lore
#0 lore raw

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

gcc  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2  -funwind-tables -fasynchronous-unwind-tables -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -g -fno-strict-aliasing -std=gnu99
-Wall -Wstrict-prototypes -Wno-unused-value
-Wdeclaration-after-statement  -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -g -fno-strict-aliasing -std=gnu99
-Wall -Wstrict-prototypes -Wno-unused-value
-Wdeclaration-after-statement  -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -g -fno-strict-aliasing -std=gnu99
-Wall -Wstrict-prototypes -Wno-unused-value
-Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD -MF
.subdirs-install.d  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -g
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes
-Wno-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD
-MF .gdbsx.d  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -g
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes
-Wno-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD
-MF .all.d  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -Werror -Wmissing-prototypes  -O1 -fno-omit-frame-pointer
-fno-optimize-sibling-calls -m64 -g -fno-strict-aliasing -std=gnu99
-Wall -Wstrict-prototypes -Wno-unused-value
-Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD -MF .gx_comm.o.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -Werror -Wmissing-prototypes
 -c -o gx_comm.o gx_comm.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

#1 lore raw

PATCH 1/1 : gdbsx: Check return of write()

Quoted 7 lines · Olaf Hering

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.

tools/debugger/gdbsx/gx/gx_comm.c +4 -2
diff -r ee4d52f0d16a tools/debugger/gdbsx/gx/gx_comm.c
@@ -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");
#2 lore raw

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

Quoted 42 lines · Gianni Tedesco
Quoted 5 lines · Olaf Hering

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.

Quoted 2 lines

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.

diff -r ee4d52f0d16a tools/debugger/gdbsx/gx/gx_comm.c

tools/debugger/gdbsx/gx/gx_comm.c Tue Nov 02 16:06:43 2010 +0000 renamed from tools/debugger/gdbsx/gx/gx_comm.c Tue Nov 02 07:35:52 2010 +0000 +4 -2
@@ -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");
Quoted 1 line

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

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw

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

Quoted 9 lines · Bruce Edge

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

With the patch applied, the line number 236 should be 237. Please apply the suggested patch, its not upstream yet.

Olaf

#4 lore raw

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

In reply to Gianni Tedesco

Gianni Tedesco writes ("[PATCH]: gdbsx: Check return of write()"):

tools/debugger/gdbsx/gx/gx_comm.c gx_getpkt (char *buf) · line 231

Quoted 3 lines
tools/debugger/gdbsx/gx/gx_comm.c +2 -1
-        write(remote_fd, "-", 1);
+        if ( write(remote_fd, "-", 1) != 1 )
+            perror("write");

Thanks. I've applied this. I fixed the formatting to be constent with the other parts of the same file, and also arranged for errors to actually cause the function to return -1 as the head comment suggests it should.

Ian.

#5 lore raw

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

Quoted 11 lines · Ian Jackson

Gianni Tedesco writes ("[PATCH]: gdbsx: Check return of write()"):

tools/debugger/gdbsx/gx/gx_comm.c gx_getpkt (char *buf) · line 231

Quoted 3 lines
tools/debugger/gdbsx/gx/gx_comm.c +2 -1
-        write(remote_fd, "-", 1);
+        if ( write(remote_fd, "-", 1) != 1 )
+            perror("write");

Thanks. I've applied this. I fixed the formatting to be constent with the other parts of the same file, and also arranged for errors to actually cause the function to return -1 as the head comment suggests it should.

What branch is this applied to?

I'm not seeing it in http://xenbits.xensource.com/xen-unstable.hg

-Bruce

Quoted 7 lines

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel