Review at  https://gerrit.osmocom.org/2659

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
---
M src/host/layer23/src/mobile/app_mobile.c
1 file changed, 7 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/59/2659/1

diff --git a/src/host/layer23/src/mobile/app_mobile.c 
b/src/host/layer23/src/mobile/app_mobile.c
index e076741..c74a93f 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -252,7 +252,7 @@
        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 @@
 
                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;

-- 
To view, visit https://gerrit.osmocom.org/2659
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a594dd1d133f0c0740dc3bff41633f94099b593
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <[email protected]>

Reply via email to