Change return value of filter_count() APIs
authorJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 17 Mar 2021 05:21:24 +0000 (14:21 +0900)
committer연정현/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <jungh.yeon@samsung.com>
Wed, 17 Mar 2021 08:02:25 +0000 (17:02 +0900)
It will return PMINFO_R_OK even if result count with given filter is 0.

Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/pkgmgrinfo_appinfo.c
src/pkgmgrinfo_pkginfo.c

index b499e13..bbb000e 100644 (file)
@@ -2465,6 +2465,7 @@ API int pkgmgrinfo_appinfo_usr_filter_count(
 {
        GHashTable *list;
        int ret;
+       int query_count;
        pkgmgrinfo_filter_x *filter;
 
        if (handle == NULL || count == NULL) {
@@ -2497,14 +2498,12 @@ API int pkgmgrinfo_appinfo_usr_filter_count(
        }
 
        ret = _appinfo_get_applications(uid, uid, filter, 0, list);
-       if (ret != PMINFO_R_OK) {
-               g_hash_table_destroy(list);
-               return PMINFO_R_ERROR;
-       }
-
-       *count = g_hash_table_size(list);
+       query_count = g_hash_table_size(list);
        g_hash_table_destroy(list);
+       if (ret == PMINFO_R_ERROR)
+               return ret;
 
+       *count = query_count;
        return PMINFO_R_OK;
 }
 
index ee3b0c6..e266630 100644 (file)
@@ -1297,6 +1297,7 @@ API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
 API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count, uid_t uid)
 {
        int ret;
+       int query_count;
        GHashTable *list = NULL;
 
        if (handle == NULL || count == NULL) {
@@ -1319,14 +1320,11 @@ API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle,
        }
 
        ret = _pkginfo_get_packages(uid, handle, PMINFO_PKGINFO_GET_BASICINFO, list);
-       if (ret != PMINFO_R_OK) {
-               g_hash_table_destroy(list);
-               return PMINFO_R_ERROR;
-       }
-       *count = g_hash_table_size(list);
-
+       query_count = g_hash_table_size(list);
        g_hash_table_destroy(list);
-
+       if (ret == PMINFO_R_ERROR)
+               return ret;
+       *count = query_count;
        return PMINFO_R_OK;
 }