summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-11-21 10:18:03 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-11-21 10:22:52 +0700
commit65110d2d99282a566b1d0e621783259bab909dce (patch)
tree1df85e5749fd3a1367c09e66ead9aedbfe3a84e1 /src
parent0e8f447c4d8c3971d5508edebf0efa6810d0cf89 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/host/layer23/src/mobile/main.c13
1 files changed, 10 insertions, 3 deletions
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 @@ static void print_help()
"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 @@ static void handle_options(int argc, char **argv)
use_mncc_sock = 1;
break;
default:
- break;
+ /* Unknown parameter passed */
+ return -EINVAL;
}
}
+
+ return 0;
}
void sighandler(int sigset)
@@ -218,7 +221,11 @@ int main(int argc, char **argv)
/* 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);