From: Phil Sutter <phil@nwl.cc>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: [iproute PATCH v2 5/7] lib/bpf: Check return value of write()
Date: Mon, 21 Aug 2017 19:08:11 +0200 [thread overview]
Message-ID: <20170821170813.29697-6-phil@nwl.cc> (raw)
In-Reply-To: <20170821170813.29697-1-phil@nwl.cc>
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@nwl.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
next prev parent reply other threads:[~2017-08-21 17:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-21 17:08 [iproute PATCH v2 0/7] Covscan: Misc fixes Phil Sutter
2017-08-21 17:08 ` [iproute PATCH v2 1/7] nstat: Avoid passing negative fd to fdopen() Phil Sutter
2017-08-22 0:23 ` Stephen Hemminger
2017-08-22 10:48 ` Phil Sutter
2017-08-21 17:08 ` [iproute PATCH v2 2/7] ss: Make sure index variable is >= 0 Phil Sutter
2017-08-22 0:34 ` Stephen Hemminger
2017-08-21 17:08 ` [iproute PATCH v2 3/7] ss: Make sure scanned index value to unix_state_map is sane Phil Sutter
2017-08-21 17:08 ` [iproute PATCH v2 4/7] netem/maketable: Check return value of fscanf() Phil Sutter
2017-08-21 17:08 ` Phil Sutter [this message]
2017-08-21 17:08 ` [iproute PATCH v2 6/7] lib/fs: Fix and simplify make_path() Phil Sutter
2017-08-21 17:08 ` [iproute PATCH v2 7/7] lib/libnetlink: Don't pass NULL parameter to memcpy() Phil Sutter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170821170813.29697-6-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).