Change in osmocom-bb[master]: mobile: abort in case of argv handling errors

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Wed Nov 21 11:11:18 UTC 2018


Vadim Yanitskiy has submitted this change and it was merged. ( https://gerrit.osmocom.org/11851 )

Change subject: mobile: abort in case of argv handling errors
......................................................................

mobile: abort in case of argv handling errors

The process should be aborted if a non-existing command line
option or an incorrect parameter value is passed.

Change-Id: Ib656ad12f12429ed15dc2a1554901ffa51148ff6
---
M src/host/layer23/src/mobile/main.c
1 file changed, 10 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/src/host/layer23/src/mobile/main.c b/src/host/layer23/src/mobile/main.c
index 115ac41..e015c30 100644
--- a/src/host/layer23/src/mobile/main.c
+++ b/src/host/layer23/src/mobile/main.c
@@ -99,7 +99,7 @@
 		"offer socket\n");
 }
 
-static void handle_options(int argc, char **argv)
+static int handle_options(int argc, char **argv)
 {
 	while (1) {
 		int option_index = 0, c;
@@ -148,9 +148,12 @@
 			use_mncc_sock = 1;
 			break;
 		default:
-			break;
+			/* Unknown parameter passed */
+			return -EINVAL;
 		}
 	}
+
+	return 0;
 }
 
 void sighandler(int sigset)
@@ -218,7 +221,11 @@
 	/* Init default stderr logging */
 	osmo_init_logging2(l23_ctx, &log_info);
 
-	handle_options(argc, argv);
+	rc = handle_options(argc, argv);
+	if (rc) { /* Abort in case of parsing errors */
+		fprintf(stderr, "Error in command line options. Exiting.\n");
+		return 1;
+	}
 
 	if (gsmtap_ip) {
 		gsmtap_inst = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1);

-- 
To view, visit https://gerrit.osmocom.org/11851
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib656ad12f12429ed15dc2a1554901ffa51148ff6
Gerrit-Change-Number: 11851
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181121/49e26344/attachment.htm>


More information about the gerrit-log mailing list