* [PATCH] rt-utils.c: Fix write() return value check
@ 2026-02-12 11:13 Gabriele Monaco
2026-02-19 18:18 ` John Kacur
0 siblings, 1 reply; 2+ messages in thread
From: Gabriele Monaco @ 2026-02-12 11:13 UTC (permalink / raw)
To: linux-rt-users, John Kacur, Clark Williams; +Cc: Gabriele Monaco
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 <gmonaco@redhat.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rt-utils.c: Fix write() return value check
2026-02-12 11:13 [PATCH] rt-utils.c: Fix write() return value check Gabriele Monaco
@ 2026-02-19 18:18 ` John Kacur
0 siblings, 0 replies; 2+ messages in thread
From: John Kacur @ 2026-02-19 18:18 UTC (permalink / raw)
To: Gabriele Monaco; +Cc: linux-rt-users, John Kacur, Clark Williams
On Thu, 12 Feb 2026, Gabriele Monaco wrote:
> 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 <gmonaco@redhat.com>
> ---
> 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
> --
Signed-off-by: John Kacur <jkacur@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-19 18:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-12 11:13 [PATCH] rt-utils.c: Fix write() return value check Gabriele Monaco
2026-02-19 18:18 ` John Kacur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox