* [PATCH] tools: usb: ffs-test: return the number of bytes written in pipe mode
@ 2026-10-11 22:34 Sasha Levin
2026-10-11 22:41 ` sashiko-bot
2026-10-11 23:09 ` Michał Nazarewicz
0 siblings, 2 replies; 3+ messages in thread
From: Sasha Levin @ 2026-10-11 22:34 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-usb, Michal Nazarewicz, linux-kernel, Sasha Levin
empty_out_buf() returns len, which the PAT_PIPE case never sets:
ffs-test.c:551:7: warning: variable 'len' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
Nothing sets pattern to PAT_PIPE, so the case is never reached and only
the warning is visible. Return nbytes once the buffer has been written
and flushed, and -1 if either fails.
Fixes: 93f2aa4ddd25c ("USB: ffs-test: FunctionFS testing program")
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/usb/ffs-test.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c
index f08060459b3f1..283db8979d67a 100644
--- a/tools/usb/ffs-test.c
+++ b/tools/usb/ffs-test.c
@@ -528,7 +528,6 @@ empty_out_buf(struct thread *ignore, const void *buf, size_t nbytes)
{
const __u8 *p;
__u8 expected;
- ssize_t ret;
size_t len;
(void)ignore;
@@ -550,9 +549,9 @@ empty_out_buf(struct thread *ignore, const void *buf, size_t nbytes)
break;
case PAT_PIPE:
- ret = fwrite(buf, nbytes, 1, stdout);
- if (ret > 0)
- fflush(stdout);
+ if (fwrite(buf, nbytes, 1, stdout) != 1 || fflush(stdout))
+ return -1;
+ len = nbytes;
break;
invalid:
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tools: usb: ffs-test: return the number of bytes written in pipe mode
2026-10-11 22:34 [PATCH] tools: usb: ffs-test: return the number of bytes written in pipe mode Sasha Levin
@ 2026-10-11 22:41 ` sashiko-bot
2026-10-11 23:09 ` Michał Nazarewicz
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-10-11 22:41 UTC (permalink / raw)
To: Sasha Levin; +Cc: linux-usb
> empty_out_buf() returns len, which the PAT_PIPE case never sets:
>
> ffs-test.c:551:7: warning: variable 'len' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
>
> Nothing sets pattern to PAT_PIPE, so the case is never reached and only
> the warning is visible. Return nbytes once the buffer has been written
> and flushed, and -1 if either fails.
>
> Fixes: 93f2aa4ddd25c ("USB: ffs-test: FunctionFS testing program")
> Assisted-by: LLM
> Signed-off-by: Sasha Levin <sashal@kernel.org>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261011223445.2328181-2-sashal@kernel.org?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools: usb: ffs-test: return the number of bytes written in pipe mode
2026-10-11 22:34 [PATCH] tools: usb: ffs-test: return the number of bytes written in pipe mode Sasha Levin
2026-10-11 22:41 ` sashiko-bot
@ 2026-10-11 23:09 ` Michał Nazarewicz
1 sibling, 0 replies; 3+ messages in thread
From: Michał Nazarewicz @ 2026-10-11 23:09 UTC (permalink / raw)
To: Sasha Levin, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel, Sasha Levin
On Sun, Oct 11 2026, Sasha Levin wrote:
> empty_out_buf() returns len, which the PAT_PIPE case never sets:
>
> ffs-test.c:551:7: warning: variable 'len' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
>
> Nothing sets pattern to PAT_PIPE, so the case is never reached and only
> the warning is visible. Return nbytes once the buffer has been written
> and flushed, and -1 if either fails.
>
> Fixes: 93f2aa4ddd25c ("USB: ffs-test: FunctionFS testing program")
> Assisted-by: LLM
> Signed-off-by: Sasha Levin <sashal@kernel.org>
Acked-by: Michał Nazarewicz <mina86@mina86.com>
> ---
> tools/usb/ffs-test.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c
> index f08060459b3f1..283db8979d67a 100644
> --- a/tools/usb/ffs-test.c
> +++ b/tools/usb/ffs-test.c
> @@ -528,7 +528,6 @@ empty_out_buf(struct thread *ignore, const void *buf, size_t nbytes)
> {
> const __u8 *p;
> __u8 expected;
> - ssize_t ret;
> size_t len;
>
> (void)ignore;
> @@ -550,9 +549,9 @@ empty_out_buf(struct thread *ignore, const void *buf, size_t nbytes)
> break;
>
> case PAT_PIPE:
> - ret = fwrite(buf, nbytes, 1, stdout);
> - if (ret > 0)
> - fflush(stdout);
> + if (fwrite(buf, nbytes, 1, stdout) != 1 || fflush(stdout))
> + return -1;
> + len = nbytes;
> break;
>
> invalid:
--
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴィツ
«If at first you don’t succeed, give up skydiving»
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-11 23:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-11 22:34 [PATCH] tools: usb: ffs-test: return the number of bytes written in pipe mode Sasha Levin
2026-10-11 22:41 ` sashiko-bot
2026-10-11 23:09 ` Michał Nazarewicz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.