Add a result value for out of memory 20/204420/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 24 Apr 2019 00:34:24 +0000 (09:34 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 24 Apr 2019 00:35:54 +0000 (09:35 +0900)
Adds:
 - AUL_R_ENOMEM

Change-Id: I5570145d765a0ce3a09c9871b5c476798cbede47
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/aul.h
src/aul_comp_context.c
src/aul_comp_info.c
src/aul_error.c

index e642b1a..57fba92 100644 (file)
@@ -33,6 +33,7 @@ extern "C" {
  * @brief Return values in AUL.
  */
 typedef enum _aul_return_val {
+       AUL_R_ENOMEM = -16,             /**< Out of memory (Since 5.5) */
        AUL_R_ENOENT = -15,             /**< App directory entry error */
        AUL_R_EREJECTED = -14,          /**< App disable for mode */
        AUL_R_ENOAPP = -13,             /**< Failed to find app ID or pkg ID */
index 5045bf6..0b2b06a 100644 (file)
@@ -199,7 +199,7 @@ API int aul_comp_context_foreach(aul_comp_context_cb callback,
        b = bundle_create();
        if (!b) {
                _E("Out of memory");
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
        }
 
        snprintf(buf, sizeof(buf), "%d", getuid());
@@ -345,7 +345,7 @@ API int aul_comp_context_create_usr(const char *comp_id, uid_t uid,
        b = bundle_create();
        if (!b) {
                _E("Out of memory");
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
        }
 
        snprintf(buf, sizeof(buf), "%d", uid);
@@ -367,19 +367,25 @@ API int aul_comp_context_create_usr(const char *comp_id, uid_t uid,
        }
 
        b = NULL;
-       if (pkt->opt & AUL_SOCK_BUNDLE)
+       if (pkt->opt & AUL_SOCK_BUNDLE) {
                b = bundle_decode(pkt->data, pkt->len);
+               if (!b) {
+                       _E("Failed to decode bundle");
+                       return AUL_R_ENOMEM;
+               }
+       }
+
        free(pkt);
 
        if (!b) {
-               _E("Failed to decode bundle");
+               _E("Invalid packet");
                return AUL_R_ERROR;
        }
 
        context = __create_comp_context(b);
        if (!context) {
                bundle_free(b);
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
        }
        bundle_free(b);
 
@@ -415,7 +421,7 @@ API int aul_comp_context_clone(aul_comp_context_h handle,
        new_context = calloc(1, sizeof(struct aul_comp_context_s));
        if (!new_context) {
                _E("Out of memory");
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
        }
 
        new_context->comp_id = strdup(context->comp_id);
@@ -453,7 +459,7 @@ err:
        if (new_context)
                __destroy_comp_context(new_context);
 
-       return AUL_R_ERROR;
+       return AUL_R_ENOMEM;
 }
 
 static int __send_request(aul_comp_context_h handle, int cmd)
@@ -466,7 +472,7 @@ static int __send_request(aul_comp_context_h handle, int cmd)
        b = bundle_create();
        if (!b) {
                _E("Out of memory");
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
        }
 
        bundle_add(b, AUL_K_COMPONENT_ID, context->comp_id);
index 120083f..fca342b 100644 (file)
@@ -228,7 +228,7 @@ static int __create_comp_info(const char *comp_id, const char *locale,
        db_path = __get_db_path(uid);
        if (!db_path) {
                _E("Failed to get db path");
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
        }
 
        db = __open_db(db_path);
@@ -242,7 +242,7 @@ static int __create_comp_info(const char *comp_id, const char *locale,
        query = sqlite3_mprintf(query_raw, locale, locale, comp_id);
        if (!query) {
                _E("Out of memory");
-               ret = AUL_R_ERROR;
+               ret = AUL_R_ENOMEM;
                goto end;
        }
 
@@ -264,7 +264,7 @@ static int __create_comp_info(const char *comp_id, const char *locale,
        info = calloc(1, sizeof(struct aul_comp_info_s));
        if (!info) {
                _E("Out of memory");
-               ret = AUL_R_ERROR;
+               ret = AUL_R_ENOMEM;
                goto end;
        }
 
@@ -302,7 +302,7 @@ API int aul_comp_info_create_usr(const char *comp_id, uid_t uid,
 
        locale = __get_system_locale();
        if (!locale)
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
 
        ret = __create_comp_info(comp_id, locale, uid, &info);
        if (ret != AUL_R_OK && uid != GLOBAL_USER)
@@ -344,7 +344,7 @@ API int aul_comp_info_clone(aul_comp_info_h handle, aul_comp_info_h *clone)
        new_info = __clone_comp_info(info);
        if (!new_info) {
                _E("Failed to clone comp info");
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
        }
 
        *clone = (aul_comp_info_h)new_info;
@@ -498,7 +498,7 @@ static int __get_localed_label(const char *comp_id, const char *locale,
        db_path = __get_db_path(uid);
        if (!db_path) {
                _E("Failed to get db path");
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
        }
 
        db = __open_db(db_path);
@@ -512,7 +512,7 @@ static int __get_localed_label(const char *comp_id, const char *locale,
        query = sqlite3_mprintf(query_raw, comp_id, locale);
        if (!query) {
                _E("Out of memory");
-               ret = AUL_R_ERROR;
+               ret = AUL_R_ENOMEM;
                goto end;
        }
 
@@ -529,7 +529,7 @@ static int __get_localed_label(const char *comp_id, const char *locale,
                if (val) {
                        *label = strdup(val);
                        if (*label == NULL)
-                               ret = AUL_R_ERROR;
+                               ret = AUL_R_ENOMEM;
                        else
                                ret = AUL_R_OK;
                } else {
@@ -696,7 +696,7 @@ API int aul_comp_info_foreach_usr_from_app(const char *app_id, uid_t uid,
        locale = __get_system_locale();
        if (!locale) {
                _E("Failed to get system locale");
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
        }
 
        ret = __get_comp_info_list(locale, uid, &list);
@@ -748,7 +748,7 @@ API int aul_comp_info_foreach_usr(uid_t uid, aul_comp_info_cb callback,
        locale = __get_system_locale();
        if (!locale) {
                _E("Failed to get system locale");
-               return AUL_R_ERROR;
+               return AUL_R_ENOMEM;
        }
 
        ret = __get_comp_info_list(locale, uid, &list);
index bfc8587..162698d 100644 (file)
@@ -27,6 +27,9 @@ int aul_error_convert(int res)
        int ret;
 
        switch (res) {
+       case -ENOMEM:
+               ret = AUL_R_ENOMEM;
+               break;
        case -EREJECTED:
                ret = AUL_R_EREJECTED;
                break;