[PATCH 4/6] osmo-nitb: be strict about cmdline args

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/OpenBSC@lists.osmocom.org/.

Neels Hofmeyr nhofmeyr at sysmocom.de
Wed Feb 24 03:56:58 UTC 2016


Abort upon unknown options and missing option arguments. This came to my
attention while rewiring the -m and -M options: passing -M without argument
would launch nitb with wrong configuration. So, rather exit immediately.

If there are legacy options that should be ignored, they deserve an own 'case:'
in the option switch. There are none that I'm aware of though.
---
 openbsc/src/osmo-nitb/bsc_hack.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c
index a89300a..6f8da98 100644
--- a/openbsc/src/osmo-nitb/bsc_hack.c
+++ b/openbsc/src/osmo-nitb/bsc_hack.c
@@ -187,7 +187,9 @@ static void handle_options(int argc, char **argv)
 			rf_ctrl_path = optarg;
 			break;
 		default:
-			/* ignore */
+			/* catch unknown options *as well as* missing arguments. */
+			fprintf(stderr, "Error in command line options. Abort.\n");
+			exit(-1);
 			break;
 		}
 	}
-- 
2.1.4




More information about the OpenBSC mailing list