[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] libxl build errors in xen-unstable



On Tue, 2011-05-31 at 09:45 +0100, Ian Campbell wrote:
> 
> [...]
> > libxl_exec.c:48: error: ignoring return value of 'atoi', declared
> with attribute warn_unused_result
> [...]
> > libxl_exec.c:224: error: ignoring return value of 'write', declared
> with attribute warn_unused_result
> [...]
> > libxl_device.c:488: error: ignoring return value of 'read', declared
> with attribute warn_unused_result
> 
> Has someone got a bit carried away with the warn_unused_result
> attribute in your distro/gcc/libc/etc? Applying that sort of attribute
> system wide to such widespread functions seems like... trouble...

Are you running Ubuntu by any chance?
https://wiki.ubuntu.com/CompilerFlags

Does this help?

Ian.


# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1306835068 -3600
# Node ID 94be5a2d500c19b8e1ee8fc18374d70cdfdb0f0f
# Parent  8cf4450955f43bb6e5fc07f20cacdf6e8cb80765
libxl: check return values of read/write

Some distros enable -D_FORTIFY_SOURCE=2 by default
(https://wiki.ubuntu.com/CompilerFlags) which adds the warn_unused_result
attribute to several functions including read(2) and write(2)

Although we don't really care about error reading or writing the libxl spawn fd
catch them anyway to keep this warning happy.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 8cf4450955f4 -r 94be5a2d500c tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Tue May 31 09:47:56 2011 +0100
+++ b/tools/libxl/libxl_device.c        Tue May 31 10:44:28 2011 +0100
@@ -485,7 +485,9 @@ again:
             }
             if (starting && FD_ISSET(starting->for_spawn->fd, &rfds)) {
                 unsigned char dummy;
-                read(starting->for_spawn->fd, &dummy, sizeof(dummy));
+                if (read(starting->for_spawn->fd, &dummy, sizeof(dummy)) != 1)
+                    LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_DEBUG,
+                                     "failed to read spawn status pipe");
             }
         }
     }
diff -r 8cf4450955f4 -r 94be5a2d500c tools/libxl/libxl_exec.c
--- a/tools/libxl/libxl_exec.c  Tue May 31 09:47:56 2011 +0100
+++ b/tools/libxl/libxl_exec.c  Tue May 31 10:44:28 2011 +0100
@@ -220,8 +220,10 @@ int libxl__spawn_spawn(libxl__gc *gc,
     rc = (WIFEXITED(status) ? WEXITSTATUS(status) :
           WIFSIGNALED(status) && WTERMSIG(status) < 127
           ? WTERMSIG(status)+128 : -1);
-    if (for_spawn)
-        write(pipes[1], &dummy, sizeof(dummy));
+    if (for_spawn) {
+        if (write(pipes[1], &dummy, sizeof(dummy)) != 1)
+            perror("libxl__spawn_spawn: unable to signal child exit to 
parent");
+    }
     _exit(rc);
 
  err_parent_pipes:



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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.