From: Sangyoon Jang Date: Tue, 4 Aug 2015 09:08:22 +0000 (+0900) Subject: Add new error code: PMINFO_R_ENOENT X-Git-Tag: accepted/tizen/mobile/20150807.073538^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F45274%2F5;p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git Add new error code: PMINFO_R_ENOENT return OK when getting no result on filter foreach api Change-Id: Ie619b75f010d24ab9407d6b8068963589714fe1f Signed-off-by: Sangyoon Jang --- diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index 0d82e12..da3d064 100644 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -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 */ diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index 46c7313..3e9e057 100644 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -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) {