[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170821170813.29697-6-phil@nwl.cc>
Date: Mon, 21 Aug 2017 19:08:11 +0200
From: Phil Sutter <phil@....cc>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org
Subject: [iproute PATCH v2 5/7] lib/bpf: Check return value of write()
This is merely to silence the compiler warning. If write to stderr
failed, assume that printing an error message will fail as well so don't
even try.
Signed-off-by: Phil Sutter <phil@....cc>
---
lib/bpf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/bpf.c b/lib/bpf.c
index 4f52ad4a8f023..be42348b3cc37 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -588,7 +588,8 @@ int bpf_trace_pipe(void)
ret = read(fd, buff, sizeof(buff) - 1);
if (ret > 0) {
- write(2, buff, ret);
+ if (write(STDERR_FILENO, buff, ret) != ret)
+ return -1;
fflush(stderr);
}
}
--
2.13.1
Powered by blists - more mailing lists