Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1 | From d6501b107940e9f548c89236d773c6d33c15a5c9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sat, 16 Apr 2016 13:28:59 -0700 |
| 4 | Subject: [PATCH 1/2] Do not ignore return value of write() |
| 5 | |
| 6 | gcc warns about ignoring return value when compiling |
| 7 | with fortify turned on. |
| 8 | |
| 9 | assert when write() fails |
| 10 | |
| 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 12 | --- |
| 13 | Upstream-Status: Submitted |
| 14 | |
| 15 | glib/tests/unix.c | 5 +++-- |
| 16 | 1 file changed, 3 insertions(+), 2 deletions(-) |
| 17 | |
| 18 | diff --git a/glib/tests/unix.c b/glib/tests/unix.c |
| 19 | index 3543458..4e7ed85 100644 |
| 20 | --- a/glib/tests/unix.c |
| 21 | +++ b/glib/tests/unix.c |
| 22 | @@ -32,14 +32,15 @@ test_pipe (void) |
| 23 | GError *error = NULL; |
| 24 | int pipefd[2]; |
| 25 | char buf[1024]; |
| 26 | - ssize_t bytes_read; |
| 27 | + ssize_t bytes_read, bytes_written; |
| 28 | gboolean res; |
| 29 | |
| 30 | res = g_unix_open_pipe (pipefd, FD_CLOEXEC, &error); |
| 31 | g_assert (res); |
| 32 | g_assert_no_error (error); |
| 33 | |
| 34 | - write (pipefd[1], "hello", sizeof ("hello")); |
| 35 | + bytes_written = write (pipefd[1], "hello", sizeof ("hello")); |
| 36 | + g_assert (bytes_written != -1 && "write() failed"); |
| 37 | memset (buf, 0, sizeof (buf)); |
| 38 | bytes_read = read (pipefd[0], buf, sizeof(buf) - 1); |
| 39 | g_assert_cmpint (bytes_read, >, 0); |
| 40 | -- |
| 41 | 2.8.0 |
| 42 | |