Fix appmanager tool 20/229720/2
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 3 Apr 2020 04:40:16 +0000 (13:40 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 3 Apr 2020 04:55:06 +0000 (13:55 +0900)
- Checks the return values

Change-Id: I769e9acec6313ce1c7f2b4b8d60705c4810e969c
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
tool/main.c

index 9a8ef55..f6db8cf 100644 (file)
@@ -49,14 +49,38 @@ static int _get_appinfo(const char *app_id)
        ret = app_manager_get_app_info(app_id, &app_info);
        if (ret != APP_MANAGER_ERROR_NONE) {
                fprintf(stderr, "No corresponding app_id for [%s]\n", app_id);
-               return APP_MANAGER_ERROR_NO_SUCH_APP;
+               return ret;
        }
 
-       app_info_get_app_id(app_info, &appid);
-       app_info_get_label(app_info, &label);
-       app_info_get_icon(app_info, &icon);
-       app_info_get_package(app_info, &package);
-       app_info_get_type(app_info, &type);
+       ret = app_info_get_app_id(app_info, &appid);
+       if (ret != APP_MANAGER_ERROR_NONE) {
+               fprintf(stderr, "Failed to get app_id. error(%d)\n", ret);
+               goto end;
+       }
+
+       ret = app_info_get_label(app_info, &label);
+       if (ret != APP_MANAGER_ERROR_NONE) {
+               fprintf(stderr, "Failed to get label. error(%d)\n", ret);
+               goto end;
+       }
+
+       ret = app_info_get_icon(app_info, &icon);
+       if (ret != APP_MANAGER_ERROR_NONE) {
+               fprintf(stderr, "Failed to get icon. error(%d)\n", ret);
+               goto end;
+       }
+
+       ret = app_info_get_package(app_info, &package);
+       if (ret != APP_MANAGER_ERROR_NONE) {
+               fprintf(stderr, "Failed to get package. error(%d)\n", ret);
+               goto end;
+       }
+
+       ret = app_info_get_type(app_info, &type);
+       if (ret != APP_MANAGER_ERROR_NONE) {
+               fprintf(stderr, "Failed to get type. error(%d)\n", ret);
+               goto end;
+       }
 
        fprintf(stderr, "appid   = [%s]\n", appid);
        fprintf(stderr, "label   = [%s]\n", label);
@@ -64,17 +88,16 @@ static int _get_appinfo(const char *app_id)
        fprintf(stderr, "package = [%s]\n", package);
        fprintf(stderr, "type    = [%s]\n", type);
 
-       ret = app_info_destroy(app_info);
-       if (ret != APP_MANAGER_ERROR_NONE)
-               return APP_MANAGER_ERROR_IO_ERROR;
-
+end:
        free(appid);
        free(label);
        free(icon);
        free(package);
        free(type);
 
-       return APP_MANAGER_ERROR_NONE;
+       app_info_destroy(app_info);
+
+       return ret;
 }
 
 int main(int argc, char **argv)