From 9ce146a8a975c065b87c1133c8fd3fb8fc0fd19b Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Wed, 17 Mar 2021 14:21:24 +0900 Subject: [PATCH] Change return value of filter_count() APIs It will return PMINFO_R_OK even if result count with given filter is 0. Signed-off-by: Junghyun Yeon --- src/pkgmgrinfo_appinfo.c | 11 +++++------ src/pkgmgrinfo_pkginfo.c | 12 +++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/pkgmgrinfo_appinfo.c b/src/pkgmgrinfo_appinfo.c index b499e13..bbb000e 100644 --- a/src/pkgmgrinfo_appinfo.c +++ b/src/pkgmgrinfo_appinfo.c @@ -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; } diff --git a/src/pkgmgrinfo_pkginfo.c b/src/pkgmgrinfo_pkginfo.c index ee3b0c6..e266630 100644 --- a/src/pkgmgrinfo_pkginfo.c +++ b/src/pkgmgrinfo_pkginfo.c @@ -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; } -- 2.7.4