summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2020-07-20 11:10:14 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2020-07-21 14:44:21 +0900
commite121aac3513ce70ada920e6850f7fcd0ef257543 (patch)
treec9eb8df3059a0bf0cce2d158620c854d8578032e
parenta44a6b2144890f3de0a70b3c0170df35825ab3d4 (diff)
downloadapp-manager-e121aac3513ce70ada920e6850f7fcd0ef257543.tar.gz
app-manager-e121aac3513ce70ada920e6850f7fcd0ef257543.tar.bz2
app-manager-e121aac3513ce70ada920e6850f7fcd0ef257543.zip
Adjust coding style
- Removes nullptr check before calling free() - Removes unnecessay if-else statements Change-Id: I9b998d46468f1d2adfe71f60dab8bf52ed887b55 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--src/app_info.c47
1 files changed, 12 insertions, 35 deletions
diff --git a/src/app_info.c b/src/app_info.c
index ada3d46..f35d0bd 100644
--- a/src/app_info.c
+++ b/src/app_info.c
@@ -164,20 +164,13 @@ static int app_info_foreach_app_filter_cb(pkgmgrinfo_appinfo_h handle, void *use
iteration_next = foreach_context->callback(info, foreach_context->user_data);
- if (info->app_id) {
- free(info->app_id);
- info->app_id = NULL;
- }
-
- if (info) {
- free(info);
- info = NULL;
- }
+ free(info->app_id);
+ free(info);
if (iteration_next == true)
return PMINFO_R_OK;
- else
- return PMINFO_R_ERROR;
+
+ return PMINFO_R_ERROR;
}
static int app_info_foreach_app_metadata_cb(const char *metadata_key, const char *metadata_value, void *user_data)
@@ -191,8 +184,8 @@ static int app_info_foreach_app_metadata_cb(const char *metadata_key, const char
iteration_next = foreach_context->callback(metadata_key, metadata_value, foreach_context->user_data);
if (iteration_next == true)
return PMINFO_R_OK;
- else
- return PMINFO_R_ERROR;
+
+ return PMINFO_R_ERROR;
}
static int app_info_foreach_category_cb(const char *category_name, void *user_data)
@@ -206,8 +199,8 @@ static int app_info_foreach_category_cb(const char *category_name, void *user_da
iteration_next = foreach_category->callback(category_name, foreach_category->user_data);
if (iteration_next == true)
return PMINFO_R_OK;
- else
- return PMINFO_R_ERROR;
+
+ return PMINFO_R_ERROR;
}
static int app_info_foreach_app_info_cb(pkgmgrinfo_appinfo_h handle, void *cb_data)
@@ -248,8 +241,8 @@ static int app_info_foreach_app_info_cb(pkgmgrinfo_appinfo_h handle, void *cb_da
if (iteration_next == true)
return PMINFO_R_OK;
- else
- return PMINFO_R_ERROR;
+
+ return PMINFO_R_ERROR;
}
int app_info_foreach_app_info(app_manager_app_info_cb callback, void *user_data)
@@ -272,7 +265,6 @@ static int _check_privilege(char *privilege)
cynara *p_cynara;
int fd;
int ret;
-
char client[SMACK_LABEL_LEN + 1] = {0,};
char uid[10] = {0,};
char *client_session = "";
@@ -401,10 +393,8 @@ API int app_info_destroy(app_info_h app_info)
if (app_info == NULL)
return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
- if (app_info->app_id) {
+ if (app_info->app_id)
free(app_info->app_id);
- app_info->app_id = NULL;
- }
pkgmgrinfo_appinfo_destroy_appinfo(app_info->pkg_app_info);
free(app_info);
@@ -477,7 +467,6 @@ API int app_info_get_label(app_info_h app_info, char **label)
API int app_info_get_localed_label(const char *app_id, const char *locale, char **label)
{
char *val = NULL;
- char *app_label_dup = NULL;
if (app_id == NULL || locale == NULL || label == NULL)
return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
@@ -485,19 +474,7 @@ API int app_info_get_localed_label(const char *app_id, const char *locale, char
if (pkgmgrinfo_appinfo_usr_get_localed_label(app_id, locale, getuid(), &val))
return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
- app_label_dup = strdup(val);
- if (app_label_dup == NULL) {
- /* LCOV_EXCL_START */
- if (val) {
- free(val);
- val = NULL;
- }
- return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
- /* LCOV_EXCL_STOP */
- }
-
- *label = app_label_dup;
- free(val);
+ *label = val;
return APP_MANAGER_ERROR_NONE;
}