aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2016-09-15 15:28:36 -0400
committerSteven Rostedt <rostedt@goodmis.org>2016-10-30 19:46:49 -0400
commit0e338e79b08567669c0f1da0e7cdd779b164f39d (patch)
tree33f1d48f645b4c6bc9ffcff436a6834a19587977
parent7a96111611ed8e67a0a371be04779609a2483a7e (diff)
downloadtrace-cmd-0e338e79b08567669c0f1da0e7cdd779b164f39d.tar.gz
trace-cmd msg: Do not perform read when expecting no data
If the size of a read is zero, do not perform the read. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-msg.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/trace-msg.c b/trace-msg.c
index 62a9c194..e53c073e 100644
--- a/trace-msg.c
+++ b/trace-msg.c
@@ -294,7 +294,7 @@ static int msg_read(int fd, void *buf, u32 size, int *n)
{
int r;
- do {
+ while (size) {
r = read(fd, buf + *n, size);
if (r < 0) {
if (errno == EINTR)
@@ -304,7 +304,7 @@ static int msg_read(int fd, void *buf, u32 size, int *n)
return -ENOTCONN;
size -= r;
*n += r;
- } while (size);
+ }
return 0;
}