Fix coverity issues (CID-109130, 108390, 106771, 110740, 110111) 60/174060/2 accepted/tizen/unified/20180403.152119 submit/tizen/20180329.051456
authorchleun.moon <chleun.moon@samsung.com>
Wed, 28 Mar 2018 01:02:04 +0000 (10:02 +0900)
committerchleun.moon <chleun.moon@samsung.com>
Wed, 28 Mar 2018 05:18:58 +0000 (14:18 +0900)
109130, 108390: Unused value
106771: Unchecked return value from library
110740: Unchecked return value
110111: Logically dead code

Change-Id: Icf17c1ca745fd6da56e0f31e1e94d7f2338496f9
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
packaging/capi-network-tethering.spec
src/tethering.c
test/tethering_test.c

index b87acb7fc041d3b09a88326d73a08abac05580c5..bc3c7171c83cafd57ab4892d2d2569964cffb9ad 100644 (file)
@@ -1,6 +1,6 @@
 Name:          capi-network-tethering
 Summary:       Tethering Framework
-Version:       1.0.56
+Version:       1.0.57
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index 448cd49db003abc9ef01b080f5697ab2869f61f4..0d7fe50884d8348662ecdf72253358508c2a29aa 100755 (executable)
@@ -1134,7 +1134,7 @@ static void __settings_reloaded_cb(GObject *source_object, GAsyncResult *res,
        GVariant *g_var;
        guint info;
        __tethering_h *th = (__tethering_h *)user_data;
-       tethering_error_e tethering_error;
+       tethering_error_e tethering_error = TETHERING_ERROR_NONE;
 
        g_var  = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
@@ -1150,7 +1150,8 @@ static void __settings_reloaded_cb(GObject *source_object, GAsyncResult *res,
                return;
        }
        g_variant_get(g_var, "(u)", &info);
-       tethering_error = __get_error(info);
+       if (tethering_error == TETHERING_ERROR_NONE)
+               tethering_error = __get_error(info);
        g_variant_unref(g_var);
 
        th->settings_reloaded_cb(tethering_error,
@@ -3439,10 +3440,17 @@ static int __remove_mac_from_file(const char *filepath, const char *mac)
        fclose(fp);
        fclose(fp1);
 
-       if ((strcmp(filepath, ALLOWED_LIST) == 0))
-               rename(TEMP_LIST, ALLOWED_LIST);
-       else if ((strcmp(filepath, BLOCKED_LIST) == 0))
-               rename(TEMP_LIST, BLOCKED_LIST);
+       if ((strcmp(filepath, ALLOWED_LIST) == 0)) {
+               if (rename(TEMP_LIST, ALLOWED_LIST) != 0) {
+                       ERR("rename is failed (%s -> %s)", TEMP_LIST, ALLOWED_LIST);
+                       return TETHERING_ERROR_OPERATION_FAILED;
+               }
+       } else if ((strcmp(filepath, BLOCKED_LIST) == 0)) {
+               if (rename(TEMP_LIST, BLOCKED_LIST) != 0) {
+                       ERR("rename is failed (%s -> %s)", TEMP_LIST, BLOCKED_LIST);
+                       return TETHERING_ERROR_OPERATION_FAILED;
+               }
+       }
 
        return TETHERING_ERROR_NONE;
 }
index 03c85bbe03764f495fa0f56745826e9cf112d50c..0ba2f815170e78066808bbdb233e9f4cf97c3433 100755 (executable)
@@ -533,28 +533,20 @@ static void __print_wifi_tethering_setting(tethering_h th)
        int error = TETHERING_ERROR_NONE;
 
        error = tethering_wifi_get_ssid(th, &ssid);
-       if (error != TETHERING_ERROR_NONE)
-               __is_err(error);
-       else
+       if (error == TETHERING_ERROR_NONE)
                g_print("\n\t** WiFi tethering SSID : %s\n", ssid);
 
        error = tethering_wifi_get_passphrase(th, &passphrase);
-       if (error != TETHERING_ERROR_NONE)
-               __is_err(error);
-       else
+       if (error == TETHERING_ERROR_NONE)
                g_print("\t** WiFi tethering passphrase : %s\n", passphrase);
 
        error = tethering_wifi_get_ssid_visibility(th, &visibility);
-       if (error != TETHERING_ERROR_NONE)
-               __is_err(error);
-       else
+       if (error == TETHERING_ERROR_NONE)
                g_print("\t** WiFi tethering ssid visibility : %s\n",
                                visibility ? "visible" : "invisible");
 
        error = tethering_wifi_get_security_type(th, &security_type);
-       if (error != TETHERING_ERROR_NONE)
-               __is_err(error);
-       else {
+       if (error == TETHERING_ERROR_NONE) {
                switch (security_type) {
                case TETHERING_WIFI_SECURITY_TYPE_NONE:
                        sec_str = "open";
@@ -573,41 +565,29 @@ static void __print_wifi_tethering_setting(tethering_h th)
        }
 
        error = tethering_wifi_get_mode(th, &hw_mode);
-       if (error != TETHERING_ERROR_NONE)
-               __is_err(error);
-       else
+       if (error == TETHERING_ERROR_NONE)
                 g_print("\t** WiFi tethering mode : %d\n", hw_mode);
 
        error = tethering_wifi_get_channel(th, &channel);
-       if (error != TETHERING_ERROR_NONE)
-               __is_err(error);
-       else
+       if (error == TETHERING_ERROR_NONE)
                 g_print("\t** WiFi tethering channel : %d\n", channel);
 
        error = tethering_wifi_get_max_connected_device(th, &max_connected);
-       if (error != TETHERING_ERROR_NONE)
-               __is_err(error);
-       else
+       if (error == TETHERING_ERROR_NONE)
                 g_print("\t** WiFi tethering max connected device : %d\n", max_connected);
 
        error = tethering_wifi_get_mac_filter(th, &mac_filter);
-       if (error != TETHERING_ERROR_NONE)
-               __is_err(error);
-       else
+       if (error == TETHERING_ERROR_NONE)
                g_print("\t** WiFi tethering mac filter : %s\n",
                                mac_filter ? "enable" : "disable");
 
        error = tethering_wifi_is_port_filtering_enabled(th, &filtering_enabled);
-       if (error != TETHERING_ERROR_NONE)
-               __is_err(error);
-       else
+       if (error == TETHERING_ERROR_NONE)
                g_print("\t** WiFi tethering port filtering : %s\n",
                                filtering_enabled ? "enable" : "disable");
 
        error = tethering_wifi_is_port_forwarding_enabled(th, &forwarding_enabled);
-       if (error != TETHERING_ERROR_NONE)
-               __is_err(error);
-       else
+       if (error == TETHERING_ERROR_NONE)
                g_print("\t** WiFi tethering port forwarding : %s\n",
                                forwarding_enabled ? "enable" : "disable");
 
@@ -1005,12 +985,9 @@ static int test_tethering_manage_mac_list(void)
        } else if (list && !option) {
                /* Add to blocked mac list */
                ret = tethering_wifi_add_blocked_mac_list(th, mac);
-       } else if (list && option) {
+       } else {
                /* Remove from blocked mac list */
                ret = tethering_wifi_remove_blocked_mac_list(th, mac);
-       } else {
-               printf("Input failed!!\n");
-               return -1;
        }
 
        if (ret < 0)