mailarchive of the pengutronix oss-tools mailing list
 help / color / mirror / Atom feed
From: Jonas Rebmann <jre@pengutronix.de>
To: oss-tools@pengutronix.de
Cc: Jonas Rebmann <jre@pengutronix.de>
Subject: [OSS-Tools] [PATCH microcom] main: error out on positional arguments
Date: Sat,  4 Jan 2025 16:17:25 +0100	[thread overview]
Message-ID: <20250104151725.12843-1-jre@pengutronix.de> (raw)

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




                 reply	other threads:[~2025-01-04 15:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250104151725.12843-1-jre@pengutronix.de \
    --to=jre@pengutronix.de \
    --cc=oss-tools@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox