Add new error code: PMINFO_R_ENOENT 74/45274/5 accepted/tizen/mobile/20150807.073538 accepted/tizen/tv/20150807.073543 accepted/tizen/wearable/20150807.073549 submit/tizen/20150807.044508
authorSangyoon Jang <s89.jang@samsung.com>
Tue, 4 Aug 2015 09:08:22 +0000 (18:08 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Wed, 5 Aug 2015 10:51:07 +0000 (19:51 +0900)
return OK when getting no result on filter foreach api

Change-Id: Ie619b75f010d24ab9407d6b8068963589714fe1f
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
include/pkgmgr-info.h
src/pkgmgr-info.c

index 0d82e12..da3d064 100644 (file)
@@ -114,6 +114,7 @@ typedef enum {
  * @brief API return values
  */
 enum {
+       PMINFO_R_ENOENT = -3,           /**< No result */
        PMINFO_R_EINVAL = -2,           /**< Invalid argument */
        PMINFO_R_ERROR = -1,            /**< General error */
        PMINFO_R_OK = 0                 /**< General success */
index 46c7313..3e9e057 100644 (file)
@@ -1348,6 +1348,7 @@ static int _pkginfo_get_filtered_foreach_pkginfo(pkgmgrinfo_filter_x *filter,
        pkgmgr_pkginfo_x *tmp;
        char *locale;
        int stop = 0;
+       int ret;
 
        if (__open_manifest_db(uid) < 0)
                return PMINFO_R_ERROR;
@@ -1358,10 +1359,11 @@ static int _pkginfo_get_filtered_foreach_pkginfo(pkgmgrinfo_filter_x *filter,
                return PMINFO_R_ERROR;
        }
 
-       if (_pkginfo_get_pkg(locale, filter, &pkginfo)) {
+       ret = _pkginfo_get_pkg(locale, filter, &pkginfo);
+       if (ret != PMINFO_R_OK) {
                free(locale);
                __close_manifest_db();
-               return PMINFO_R_ERROR;
+               return (ret == PMINFO_R_ENOENT) ? PMINFO_R_OK : PMINFO_R_ERROR;
        }
 
        tmp = pkginfo;
@@ -1823,14 +1825,14 @@ static int _pkginfo_get_pkg(const char *locale, pkgmgrinfo_filter_x *filter,
 
        sqlite3_finalize(stmt);
 
-       if (*pkginfo) {
-               LISTHEAD(*pkginfo, info);
-               *pkginfo = info;
-       } else {
+       if (*pkginfo == NULL) {
                LOGE("no result");
-               return PMINFO_R_ERROR;
+               return PMINFO_R_ENOENT;
        }
 
+       LISTHEAD(*pkginfo, info);
+       *pkginfo = info;
+
        return PMINFO_R_OK;
 }
 
@@ -3428,9 +3430,9 @@ static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
                void *user_data)
 {
        pkgmgr_appinfo_x *appinfo = NULL;
-       pkgmgr_appinfo_x *next;
        pkgmgr_appinfo_x *tmp;
        char *locale;
+       int ret;
 
        if (__open_manifest_db(uid) < 0)
                return PMINFO_R_ERROR;
@@ -3441,10 +3443,11 @@ static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
                return PMINFO_R_ERROR;
        }
 
-       if (_appinfo_get_app(locale, filter, &appinfo)) {
+       ret = _appinfo_get_app(locale, filter, &appinfo);
+       if (ret != PMINFO_R_OK) {
                free(locale);
                __close_manifest_db();
-               return PMINFO_R_ERROR;
+               return (ret == PMINFO_R_ENOENT) ? PMINFO_R_OK : PMINFO_R_ERROR;
        }
 
        for (tmp = appinfo; tmp; tmp = tmp->next) {
@@ -3917,14 +3920,14 @@ static int _appinfo_get_app(const char *locale, pkgmgrinfo_filter_x *filter,
 
        sqlite3_finalize(stmt);
 
-       if (*appinfo) {
-               LISTHEAD(*appinfo, info);
-               *appinfo = info;
-       } else {
+       if (*appinfo == NULL) {
                LOGE("no result");
-               return PMINFO_R_ERROR;
+               return PMINFO_R_ENOENT;
        }
 
+       LISTHEAD(*appinfo, info);
+       *appinfo = info;
+
        return PMINFO_R_OK;
 }
 
@@ -5328,7 +5331,7 @@ API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
        if (list == NULL) {
                LOGE("no result");
                __close_manifest_db();
-               return PMINFO_R_ERROR;
+               return PMINFO_R_OK;
        }
 
        for (tmp = list; tmp; tmp = tmp->next) {