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@nwl.cc>
This commit is contained in:
Phil Sutter 2017-08-24 11:41:29 +02:00 committed by Stephen Hemminger
parent 92963d136d
commit b5c78e1b2c
1 changed files with 2 additions and 1 deletions

View File

@ -591,7 +591,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);
}
}