Fix coverity issues (CID-109130, 108390, 106771, 110740, 110111)
[platform/core/api/tethering.git] / src / tethering.c
index 448cd49..0d7fe50 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;
 }