From: Daniel Wagner <daniel.wag...@bmw-carit.de>

Let's remove the small allocations error path because glib will
abort on memory exhausting anyway. Basically we remove dead code.
---
 plugins/session_policy_local.c | 39 ++++-----------------------------------
 1 file changed, 4 insertions(+), 35 deletions(-)

diff --git a/plugins/session_policy_local.c b/plugins/session_policy_local.c
index af1293f..9c28184 100644
--- a/plugins/session_policy_local.c
+++ b/plugins/session_policy_local.c
@@ -115,12 +115,10 @@ static struct policy_data *create_policy(const char 
*ident)
 
        DBG("ident %s", ident);
 
-       policy = g_try_new0(struct policy_data, 1);
-       if (policy == NULL)
-               return NULL;
+       policy = g_new0(struct policy_data, 1);
+       policy->refcount = 1;
 
        policy->config = connman_session_create_default_config();
-       policy->refcount = 1;
        policy->ident = g_strdup(ident);
 
        g_hash_table_replace(policy_hash, policy->ident, policy);
@@ -161,10 +159,6 @@ static void selinux_context_reply(const unsigned char 
*context, void *user_data,
                goto done;
 
        ctx = g_strdup((const gchar*)context);
-       if (ctx == NULL) {
-               err = -ENOMEM;
-               goto done;
-       }
 
        DBG("SELinux context %s", ctx);
 
@@ -178,13 +172,8 @@ static void selinux_context_reply(const unsigned char 
*context, void *user_data,
        if (policy != NULL) {
                policy_ref(policy);
                policy->session = data->session;
-       } else {
+       } else
                policy = create_policy(ident);
-               if (policy == NULL) {
-                       err = -ENOMEM;
-                       goto done;
-               }
-       }
 
        g_hash_table_replace(session_hash, data->session, policy);
        config = policy->config;
@@ -207,9 +196,7 @@ static int policy_local_create(struct connman_session 
*session,
 
        DBG("session %p", session);
 
-       data = g_try_new0(struct create_data, 1);
-       if (data == NULL)
-               return -ENOMEM;
+       data = g_new0(struct create_data, 1);
 
        data->session = session;
        data->callback = callback;
@@ -290,8 +277,6 @@ static int load_policy(struct policy_data *policy)
        int i, err = 0;
 
        pathname = g_strdup_printf("%s/%s", POLICYDIR, policy->ident);
-       if(pathname == NULL)
-               return -ENOMEM;
 
        err = load_keyfile(pathname, &keyfile);
        if (err < 0) {
@@ -350,8 +335,6 @@ static int load_policy(struct policy_data *policy)
        } else {
                config->allowed_bearers = g_slist_append(NULL,
                                GINT_TO_POINTER(CONNMAN_SERVICE_TYPE_UNKNOWN));
-               if (config->allowed_bearers == NULL)
-                       err = -ENOMEM;
        }
 
        g_key_file_free(keyfile);
@@ -439,11 +422,6 @@ static int read_policies(void)
                        struct policy_data *policy;
 
                        policy = create_policy(file);
-                       if (policy == NULL) {
-                               err = -ENOMEM;
-                               break;
-                       }
-
                        err = load_policy(policy);
                        if (err < 0)
                                break;
@@ -473,17 +451,8 @@ static int session_policy_local_init(void)
 
        session_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal,
                                                NULL, NULL);
-       if (session_hash == NULL) {
-               err = -ENOMEM;
-               goto err;
-       }
-
        policy_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
                                        NULL, cleanup_policy);
-       if (policy_hash == NULL) {
-               err = -ENOMEM;
-               goto err;
-       }
 
        err = connman_inotify_register(POLICYDIR, notify_handler);
        if (err < 0)
-- 
1.8.1.3.566.gaa39828

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to