Fix the issues that the results of APIs aren't handled accepted/tizen_4.0_unified tizen_4.0 accepted/tizen/4.0/unified/20181226.234114 submit/tizen_4.0/20181221.021633
authorSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 26 Mar 2018 03:48:35 +0000 (12:48 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Fri, 21 Dec 2018 01:59:58 +0000 (10:59 +0900)
This is for solving some coverity issues

Change-Id: I46cc67240bff904c92886ed316be147028222c57
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
rmi/app-proxy.h
rmi/package-proxy.h
server/manager.cpp
server/packman.cpp

index 2790f28..6e154f0 100644 (file)
@@ -39,9 +39,9 @@ public:
                std::string type;
                std::string icon;
                std::string label;
-               int componentType;
-               bool isNoDisplayed;
-               bool isTaskManaged;
+               int componentType = 0;
+               bool isNoDisplayed = false;
+               bool isTaskManaged = false;
 
                REFLECTABLE
                (krate, id, locale, package, type, icon, label,
index c4671ef..ccf56d1 100644 (file)
@@ -48,9 +48,9 @@ public:
                std::string version;
                std::string apiVersion;
                std::string mainAppId;
-               bool isSystem;
-               bool isRemovable;
-               bool isPreload;
+               bool isSystem = false;
+               bool isRemovable = false;
+               bool isPreload = false;
 
                REFLECTABLE
                (krate, id, locale, type, icon, label, description, author,
index ea3ac09..1fa9272 100755 (executable)
@@ -325,23 +325,33 @@ void notiProxyInsert(const runtime::User& owner, const runtime::User& user, int
 {
        std::string krateLauncherUri;
        notification_h newNoti;
-       app_control_h appControl;
+       app_control_h appControl = NULL;
        char* pkgId;
+       int ret;
 
        notification_clone(noti, &newNoti);
 
        notification_get_pkgname(noti, &pkgId);
        try {
                PackageInfo pkg(pkgId, user.getUid());
-               notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON, pkg.getIcon().c_str());
+               ret = notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON, pkg.getIcon().c_str());
+               if (ret != NOTIFICATION_ERROR_NONE) {
+                       throw runtime::Exception("notification_set_image");
+               }
        } catch (runtime::Exception &e) {
-               notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON, DEFAULT_ICON_PATH);
+               ret = notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON, DEFAULT_ICON_PATH);
+               if (ret != NOTIFICATION_ERROR_NONE) {
+                       ERROR(std::string("Failed to set an image to noti : ") + e.what());
+               }
        }
 
-       notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON_SUB, NOTIFICATION_SUB_ICON_PATH);
+       ret = notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON_SUB, NOTIFICATION_SUB_ICON_PATH);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ERROR("Failed to set a sub-image to noti");
+       }
 
-       notification_get_launch_option(newNoti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, (void *)&appControl);
-       if (appControl != NULL) {
+       ret = notification_get_launch_option(newNoti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, (void *)&appControl);
+       if (ret == NOTIFICATION_ERROR_NONE && appControl != NULL) {
                char* appId = NULL, *uri = NULL;
 
                app_control_get_app_id(appControl, &appId);
@@ -362,6 +372,7 @@ void notiProxyInsert(const runtime::User& owner, const runtime::User& user, int
                app_control_set_app_id(appControl, KRATE_DELEGATOR_APP);
                app_control_set_uri(appControl, krateLauncherUri.c_str());
                notification_set_launch_option(newNoti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl);
+               app_control_destroy(appControl);
        }
 
        notification_post_for_uid(newNoti, owner.getUid());
@@ -385,6 +396,7 @@ void notiProxyUpdate(const runtime::User& owner, const runtime::User& user, int
        std::unordered_map<int, notification_h>::iterator it;
        double progress;
        char *str;
+       int ret;
 
        it = notiHandleMap.find(privId);
        if (it == notiHandleMap.end()) {
@@ -413,8 +425,13 @@ void notiProxyUpdate(const runtime::User& owner, const runtime::User& user, int
        };
 
        for (notification_image_type_e type : imageTypes) {
-               notification_get_image(noti, type, &str);
-               notification_set_image(it->second, type, str);
+               ret = notification_get_image(noti, type, &str);
+               if (ret == NOTIFICATION_ERROR_NONE) {
+                       ret = notification_set_image(it->second, type, str);
+                       if (ret != NOTIFICATION_ERROR_NONE) {
+                               ERROR("Failed to copy an image of noti");
+                       }
+               }
        }
 
        notification_text_type_e textTypes[] = {
@@ -440,8 +457,13 @@ void notiProxyUpdate(const runtime::User& owner, const runtime::User& user, int
        };
 
        for (notification_text_type_e type : textTypes) {
-               notification_get_text(noti, type, &str);
-               notification_set_text(it->second, type, str, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               ret = notification_get_text(noti, type, &str);
+               if (ret == NOTIFICATION_ERROR_NONE) {
+                       ret = notification_set_text(it->second, type, str, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+                       if (ret != NOTIFICATION_ERROR_NONE) {
+                               ERROR("Failed to copy a text of noti");
+                       }
+               }
        }
 
        notification_get_size(noti, &progress);
@@ -541,6 +563,12 @@ int Manager::createKrate(const std::string& name, const std::string& manifest)
                                for (int i = 0; i < GUMD_RETRY_COUNT && guser == NULL; i++) {
                                        guser = gum_user_create_sync(FALSE);
                                }
+
+                               if (guser == NULL) {
+                                       ret = 1;
+                                       break;
+                               }
+
                                g_object_set(G_OBJECT(guser), "username", name.c_str(),
                                                                        "usertype", GUM_USERTYPE_SECURITY, NULL);
                                ret = gum_user_add_sync(guser);
@@ -646,6 +674,12 @@ int Manager::removeKrate(const std::string& name)
                                for (int i = 0; i < GUMD_RETRY_COUNT && guser == NULL; i++) {
                                        guser = gum_user_get_sync(user.getUid(), FALSE);
                                }
+
+                               if (guser == NULL) {
+                                       ret = 1;
+                                       break;
+                               }
+
                                ret = gum_user_delete_sync(guser, TRUE);
                                g_object_unref(guser);
                        }
index 9425374..4e2cce7 100644 (file)
@@ -37,7 +37,10 @@ int AppListCallback(pkgmgrinfo_appinfo_h handle, void *data)
 int PackageListCallback(pkgmgrinfo_pkginfo_h handle, void *data)
 {
        char* pkgid = nullptr;
-       ::pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+
+       if (::pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid) != PMINFO_R_OK) {
+               return 0;
+       }
 
        std::vector<std::string>* packageList = static_cast<std::vector<std::string>*>(data);
        packageList->push_back(pkgid);
@@ -266,8 +269,15 @@ void ApplicationInfo::load(pkgmgrinfo_appinfo_h handle) {
                componentType = static_cast<int>(comp);
        }
 
-       ::pkgmgrinfo_appinfo_is_nodisplay(handle, &noDisplayed);
-       ::pkgmgrinfo_appinfo_is_taskmanage(handle, &taskManaged);
+       ret = ::pkgmgrinfo_appinfo_is_nodisplay(handle, &noDisplayed);
+       if (ret != PMINFO_R_OK) {
+               noDisplayed = false;
+       }
+
+       ret = ::pkgmgrinfo_appinfo_is_taskmanage(handle, &taskManaged);
+       if (ret != PMINFO_R_OK) {
+               taskManaged = false;
+       }
 }
 
 const std::string& ApplicationInfo::getId() const