[PATCH] rt-utils.c: Fix write() return value check
Gabriele Monaco <[email protected]>
| Newsgroups | org.kernel.vger.linux-rt-users |
|---|---|
| Message-ID | <[email protected]> |
The write() return value check in tracemark() is a copy-paste from the
one in tracing_stop() which checks for 2 bytes to be written. As a
result, tracemark() is almost always warning.
Check for the write() return value to be equal to the written length,
which is the value returned if no error occurred.
While at it, add "\n" to the warn messages.
Fixes: 60d60540c009 ("rt-utils.c: Check return values of write()")
Signed-off-by: Gabriele Monaco <[email protected]>
---
src/lib/rt-utils.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
index d800b5f..aa70c78 100644
--- a/src/lib/rt-utils.c
+++ b/src/lib/rt-utils.c
@@ -437,8 +437,8 @@ void tracemark(char *fmt, ...)
/* write the tracemark message */
ret = write(tracemark_fd, tracebuf, len);
- if (ret != 2)
- warn("trace stop write failed");
+ if (ret != len)
+ warn("trace mark write failed\n");
}
void tracing_stop(void)
@@ -449,7 +449,7 @@ void tracing_stop(void)
return;
ret = write(trace_fd, "0\n", 2);
if (ret != 2)
- warn("trace stop write failed");
+ warn("trace stop write failed\n");
}
void enable_trace_mark(void)
base-commit: 4e68b52f0e0c9777c91088948374c6ee3d4a1f6b
--
2.53.0