summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-05-17 00:03:33 +0300
committerVadim Yanitskiy <axilirator@gmail.com>2017-05-25 02:11:53 +0300
commit03aace58181e2785616a497b9e76fbb6ae1bad19 (patch)
treec32f4adf8555112b878c06cfb60135ef24c3942b
parent0f396942106c861b109743d017861aa8bf0c78d9 (diff)
host/app_mobile.c: do not exit in mobile_new()
Previously, if there was any error during a new osmocom_ms structure allocation, the mobile_new() used to call exit() directly. Since we always check return value of this function it would be more correct to return NULL in any bad case. Change-Id: I9a594dd1d133f0c0740dc3bff41633f94099b593
-rw-r--r--src/host/layer23/src/mobile/app_mobile.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c
index e0767416..c74a93ff 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -252,7 +252,7 @@ struct osmocom_ms *mobile_new(char *name)
ms = talloc_zero(l23_ctx, struct osmocom_ms);
if (!ms) {
fprintf(stderr, "Failed to allocate MS\n");
- exit(1);
+ return NULL;
}
llist_add_tail(&ms->entity, &ms_list);
@@ -423,11 +423,12 @@ int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *),
printf("No Mobile Station defined, creating: MS '1'\n");
ms = mobile_new("1");
- if (ms) {
- rc = mobile_init(ms);
- if (rc < 0)
- return rc;
- }
+ if (!ms)
+ return -1;
+
+ rc = mobile_init(ms);
+ if (rc < 0)
+ return rc;
}
quit = 0;