From 71a76245bd2732f334d38efa660e67d814f66e25 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Thu, 23 Jun 2016 15:30:58 +0900 Subject: [PATCH] keep consistent results(empty) of {NULL} values of pkgmgr db. Change-Id: I003b111eaf4aaeaacbba42a46e84827b7f6cba65 Signed-off-by: jongmyeongko --- src/pkgmgrinfo_appinfo.c | 5 +++++ src/pkgmgrinfo_pkginfo.c | 25 ++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/pkgmgrinfo_appinfo.c b/src/pkgmgrinfo_appinfo.c index d5a876e..8d26260 100644 --- a/src/pkgmgrinfo_appinfo.c +++ b/src/pkgmgrinfo_appinfo.c @@ -1545,6 +1545,11 @@ API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon) if (info->app_info == NULL) return PMINFO_R_ERROR; + if (info->app_info->icon == NULL) { + *icon = ""; + return PMINFO_R_OK; + } + for (tmp = info->app_info->icon; tmp; tmp = tmp->next) { ptr = (icon_x *)tmp->data; if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || diff --git a/src/pkgmgrinfo_pkginfo.c b/src/pkgmgrinfo_pkginfo.c index 7daec75..1b5548e 100644 --- a/src/pkgmgrinfo_pkginfo.c +++ b/src/pkgmgrinfo_pkginfo.c @@ -987,13 +987,24 @@ API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkg API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size) { pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + char *temp = NULL; retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - if (info->pkg_info == NULL || info->pkg_info->package_size == NULL) + if (info->pkg_info == NULL) return PMINFO_R_ERROR; + if (info->pkg_info->package_size == NULL) { + temp = strdup(""); + if (temp == NULL) { + _LOGE("out of memory"); + return PMINFO_R_ERROR; + } else { + info->pkg_info->package_size = temp; + } + } + *size = atoi((char *)info->pkg_info->package_size); return PMINFO_R_OK; @@ -1175,6 +1186,8 @@ API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon) for (tmp = info->pkg_info->icon; tmp; tmp = tmp->next) { ptr = (icon_x *)tmp->data; + if (ptr && ptr->text == NULL) + ptr->text = strdup(""); if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || !strcasecmp(ptr->text, "(null)") || strcmp(ptr->lang, locale)) @@ -1186,6 +1199,8 @@ API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon) locale = DEFAULT_LOCALE; for (tmp = info->pkg_info->icon; tmp; tmp = tmp->next) { ptr = (icon_x *)tmp->data; + if (ptr && ptr->text == NULL) + ptr->text = strdup(""); if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || strcmp(ptr->lang, locale)) continue; @@ -1211,6 +1226,8 @@ API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label) for (tmp = info->pkg_info->label; tmp != NULL; tmp = tmp->next) { ptr = (label_x *)tmp->data; + if (ptr && ptr->text == NULL) + ptr->text = strdup(""); if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || strcmp(ptr->lang, locale)) continue; @@ -1221,6 +1238,8 @@ API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label) locale = DEFAULT_LOCALE; for (tmp = info->pkg_info->label; tmp != NULL; tmp = tmp->next) { ptr = (label_x *)tmp->data; + if (ptr && ptr->text == NULL) + ptr->text = strdup(""); if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || strcmp(ptr->lang, locale)) continue; @@ -1246,6 +1265,8 @@ API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **d for (tmp = info->pkg_info->description; tmp; tmp = tmp->next) { ptr = (description_x *)tmp->data; + if (ptr && ptr->text == NULL) + ptr->text = strdup(""); if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || strcmp(ptr->lang, locale)) continue; @@ -1256,6 +1277,8 @@ API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **d locale = DEFAULT_LOCALE; for (tmp = info->pkg_info->description; tmp; tmp = tmp->next) { ptr = (description_x *)tmp->data; + if (ptr && ptr->text == NULL) + ptr->text = strdup(""); if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || strcmp(ptr->lang, locale)) continue; -- 2.7.4