blob: f3a006963339a425e3405d0e76ec54ca621ebe60 [file] [log] [blame]
Andrew Geissler4b740dc2020-05-05 08:54:39 -05001From 658c034d92027dc8af5f784cae852123fac79b19 Mon Sep 17 00:00:00 2001
Patrick Williamsc0f7c042017-02-23 20:41:17 -06002From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 16 Apr 2016 13:28:59 -0700
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08004Subject: [PATCH] Do not ignore return value of write()
Patrick Williamsc0f7c042017-02-23 20:41:17 -06005
6gcc warns about ignoring return value when compiling
7with fortify turned on.
8
9assert when write() fails
10
Patrick Williamsc0f7c042017-02-23 20:41:17 -060011Upstream-Status: Submitted
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012Signed-off-by: Khem Raj <raj.khem@gmail.com>
Patrick Williamsc0f7c042017-02-23 20:41:17 -060013
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080014---
Patrick Williamsc0f7c042017-02-23 20:41:17 -060015 glib/tests/unix.c | 5 +++--
16 1 file changed, 3 insertions(+), 2 deletions(-)
17
18diff --git a/glib/tests/unix.c b/glib/tests/unix.c
Andrew Geissler4b740dc2020-05-05 08:54:39 -050019index 7639d06..f941141 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -060020--- a/glib/tests/unix.c
21+++ b/glib/tests/unix.c
Andrew Geissler4b740dc2020-05-05 08:54:39 -050022@@ -33,14 +33,15 @@ test_pipe (void)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060023 GError *error = NULL;
24 int pipefd[2];
25 char buf[1024];
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080026- gssize bytes_read;
27+ gssize bytes_read, bytes_written;
Patrick Williamsc0f7c042017-02-23 20:41:17 -060028 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);