diff options
author | Luke Deller <luke@deller.id.au> | 2015-01-16 01:14:54 +1100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-01-15 14:55:45 +0000 |
commit | 231e74be5ed724a18cc5867212270e46a8fda9bc (patch) | |
tree | 34d4713133b5dcc7fae04cc9dabdcff9e03c68e4 | |
parent | 3cb3396e4a4b36e5a05892da16b076feaef6b2b1 (diff) |
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@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/unx/glxtest.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/vcl/unx/glxtest.cxx b/vcl/unx/glxtest.cxx index 8b9408debadc..75022b6af14c 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 */ |