diff --git a/src/usb_moded-config.c b/src/usb_moded-config.c index d8997eb..423cf0a 100644 --- a/src/usb_moded-config.c +++ b/src/usb_moded-config.c @@ -355,22 +355,14 @@ char * get_mode_setting(void) * @param key: key value of the entry we want to read * @new_value: potentially new value we want to compare against * - * @return: 1 when the old value is the same as the new one, 0 otherwise + * @return: 0 when the old value is the same as the new one, 1 otherwise */ int config_value_changed(GKeyFile *settingsfile, const char *entry, const char *key, const char *new_value) { - char *old = g_key_file_get_string(settingsfile, entry, key, NULL); - if (old) - { - gboolean unchanged = (g_strcmp0(old, new_value) == 0); - g_free(old); - if (unchanged) - { - return 1; - } - } - - return 0; + char *old_value = g_key_file_get_string(settingsfile, entry, key, NULL); + int changed = (g_strcmp0(old_value, new_value) != 0); + g_free(old_value); + return changed; } set_config_result_t set_config_setting(const char *entry, const char *key, const char *value) @@ -384,7 +376,7 @@ set_config_result_t set_config_setting(const char *entry, const char *key, const test = g_key_file_load_from_file(settingsfile, FS_MOUNT_CONFIG_FILE, G_KEY_FILE_NONE, NULL); if(test) { - if(config_value_changed(settingsfile, entry, key, value)) + if(!config_value_changed(settingsfile, entry, key, value)) { g_key_file_free(settingsfile); return SET_CONFIG_UNCHANGED; @@ -537,7 +529,7 @@ set_config_result_t set_network_setting(const char *config, const char *setting) set_config_result_t ret = SET_CONFIG_ERROR; if (test) { - if(config_value_changed(settingsfile, NETWORK_ENTRY, config, setting)) + if(!config_value_changed(settingsfile, NETWORK_ENTRY, config, setting)) { g_key_file_free(settingsfile); return SET_CONFIG_UNCHANGED;