From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Sat, 04 Jan 2025 16:18:00 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tU5ua-00GfBf-0Y for lore@lore.pengutronix.de; Sat, 04 Jan 2025 16:18:00 +0100 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1tU5uZ-0007St-4C; Sat, 04 Jan 2025 16:17:59 +0100 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1tU5uW-0007S6-3S; Sat, 04 Jan 2025 16:17:56 +0100 From: Jonas Rebmann To: oss-tools@pengutronix.de Date: Sat, 4 Jan 2025 16:17:25 +0100 Message-Id: <20250104151725.12843-1-jre@pengutronix.de> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [OSS-Tools] [PATCH microcom] main: error out on positional arguments X-BeenThere: oss-tools@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: Pengutronix Public Open-Source-Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonas Rebmann Sender: "OSS-Tools" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: oss-tools-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false 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 --- 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