[Libreoffice-commits] core.git: vcl/unx

Luke Deller luke at deller.id.au
Thu Jan 15 06:56:13 PST 2015


 vcl/unx/glxtest.cxx |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 231e74be5ed724a18cc5867212270e46a8fda9bc
Author: Luke Deller <luke at deller.id.au>
Date:   Fri Jan 16 01:14:54 2015 +1100

    Fix warning about ignoring write() return val
    
    glibc declares write() with the warn_unused_result attribute, so we need
    to check the return value to avoid a compiler warning.
    
    (This warning only seems to occur when gcc optimizations are enabled)
    
    Change-Id: I31962aae63d0a12eecfe44bb7920a68b29c05d8a
    Reviewed-on: https://gerrit.libreoffice.org/13927
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/glxtest.cxx b/vcl/unx/glxtest.cxx
index 8b9408d..75022b6 100644
--- a/vcl/unx/glxtest.cxx
+++ b/vcl/unx/glxtest.cxx
@@ -73,8 +73,12 @@ static func_ptr_type cast(void *ptr)
 
 static void fatal_error(const char *str)
 {
-  write(write_end_of_the_pipe, str, strlen(str));
-  write(write_end_of_the_pipe, "\n", 1);
+  int length = strlen(str);
+  if (write(write_end_of_the_pipe, str, length) != length
+      || write(write_end_of_the_pipe, "\n", 1) != 1)
+  {
+      /* Cannot write to pipe. Fall through to call _exit */
+  }
   _exit(EXIT_FAILURE);
 }
 
@@ -88,7 +92,10 @@ x_error_handler(Display *, XErrorEvent *ev)
                         ev->error_code,
                         ev->request_code,
                         ev->minor_code);
-  write(write_end_of_the_pipe, buf, length);
+  if (write(write_end_of_the_pipe, buf, length) != length)
+  {
+      /* Cannot write to pipe. Fall through to call _exit */
+  }
   _exit(EXIT_FAILURE);
   return 0;
 }
@@ -233,7 +240,8 @@ void glxtest()
   dlclose(libgl);
 
   ///// Finally write data to the pipe
-  write(write_end_of_the_pipe, buf, length);
+  if (write(write_end_of_the_pipe, buf, length) != length)
+    fatal_error("Could not write to pipe");
 }
 
 /** \returns true in the child glxtest process, false in the parent process */


More information about the Libreoffice-commits mailing list