mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] commands: usbgadget: improve error message on failure
@ 2025-11-05  9:36 Ahmad Fatoum
  2025-11-06  7:43 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-11-05  9:36 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug, Ahmad Fatoum

The command reports EINVAL when encountering an option it doesn't
understand and the help text for other errors.

It's more useful to users to flip them around, so they can see e.g.
-EPERM if a security policy prevented the command from working.

Reported-by: Fabian Pflug <f.pflug@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 commands/usbgadget.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/commands/usbgadget.c b/commands/usbgadget.c
index 1cd8c915b1b1..2edccca1f36c 100644
--- a/commands/usbgadget.c
+++ b/commands/usbgadget.c
@@ -20,7 +20,6 @@ static int do_usbgadget(int argc, char *argv[])
 {
 	struct usbgadget_funcs funcs = {};
 	int opt;
-	int ret;
 
 	while ((opt = getopt(argc, argv, "asdA::D::S::b")) > 0) {
 		switch (opt) {
@@ -47,12 +46,11 @@ static int do_usbgadget(int argc, char *argv[])
 			usb_multi_unregister();
 			return 0;
 		default:
-			return -EINVAL;
+			return COMMAND_ERROR_USAGE;
 		}
 	}
 
-	ret = usbgadget_prepare_register(&funcs);
-	return ret ? COMMAND_ERROR_USAGE : 0;
+	return usbgadget_prepare_register(&funcs);
 }
 
 BAREBOX_CMD_HELP_START(usbgadget)
-- 
2.47.3




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-06  7:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-05  9:36 [PATCH] commands: usbgadget: improve error message on failure Ahmad Fatoum
2025-11-06  7:43 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox