mailarchive of the pengutronix oss-tools mailing list
 help / color / mirror / Atom feed
* [OSS-Tools] [PATCH microcom] main: error out on positional arguments
@ 2025-01-04 15:17 Jonas Rebmann
  2025-11-24 11:24 ` Roland Hieber
  0 siblings, 1 reply; 3+ messages in thread
From: Jonas Rebmann @ 2025-01-04 15:17 UTC (permalink / raw)
  To: oss-tools; +Cc: Jonas Rebmann

As microcom makes no use of positional arguments, error out and show
usage if a positional argument is presented.

Without this patch, invalid usage involving a positional such as
microcom /dev/ttyUSB0 is silently ignored.

Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
---
 microcom.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/microcom.c b/microcom.c
index 2b3d484..974c0cf 100644
--- a/microcom.c
+++ b/microcom.c
@@ -183,6 +183,10 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	if (optind < argc) {
+		main_usage(1, "", "");
+	}
+
 	if (answerback) {
 		ret = asprintf(&answerback, "%s\n", answerback);
 		if (ret < 0)
-- 
2.39.5




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

end of thread, other threads:[~2025-11-24 13:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-04 15:17 [OSS-Tools] [PATCH microcom] main: error out on positional arguments Jonas Rebmann
2025-11-24 11:24 ` Roland Hieber
2025-11-24 13:32   ` Jonas Rebmann

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