ifcfg-rh: remove dead code from write_ip4_setting()

s_ip4 cannot be NULL and fake_ip4 is never TRUE.

Found by Coverity.

Fixes: cf7b8866ce
This commit is contained in:
Thomas Haller
2016-09-09 00:59:21 +02:00
parent 1a85103765
commit 8bae6e588f

View File

@@ -2010,8 +2010,6 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
gint priority; gint priority;
int timeout; int timeout;
GString *searches; GString *searches;
gboolean success = FALSE;
gboolean fake_ip4 = FALSE;
const char *method = NULL; const char *method = NULL;
s_ip4 = nm_connection_get_setting_ip4_config (connection); s_ip4 = nm_connection_get_setting_ip4_config (connection);
@@ -2075,12 +2073,6 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
return TRUE; return TRUE;
} }
/* Temporarily create fake IP4 setting if missing; method set to DHCP above */
if (!s_ip4) {
s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new ();
fake_ip4 = TRUE;
}
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO))
svSetValue (ifcfg, "BOOTPROTO", "dhcp", FALSE); svSetValue (ifcfg, "BOOTPROTO", "dhcp", FALSE);
else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
@@ -2255,7 +2247,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
if (!route_path) { if (!route_path) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not get route file path for '%s'", ifcfg->fileName); "Could not get route file path for '%s'", ifcfg->fileName);
goto out; return FALSE;
} }
if (utils_has_route_file_new_syntax (route_path)) { if (utils_has_route_file_new_syntax (route_path)) {
@@ -2266,7 +2258,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not create route file '%s'", route_path); "Could not create route file '%s'", route_path);
g_free (route_path); g_free (route_path);
goto out; return FALSE;
} }
g_free (route_path); g_free (route_path);
@@ -2317,14 +2309,14 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
} }
if (!svWriteFile (routefile, 0644, error)) { if (!svWriteFile (routefile, 0644, error)) {
svCloseFile (routefile); svCloseFile (routefile);
goto out; return FALSE;
} }
svCloseFile (routefile); svCloseFile (routefile);
} else { } else {
write_route_file_legacy (route_path, s_ip4, error); write_route_file_legacy (route_path, s_ip4, error);
g_free (route_path); g_free (route_path);
if (error && *error) if (error && *error)
goto out; return FALSE;
} }
timeout = nm_setting_ip_config_get_dad_timeout (s_ip4); timeout = nm_setting_ip_config_get_dad_timeout (s_ip4);
@@ -2343,13 +2335,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
else else
svSetValue (ifcfg, "IPV4_DNS_PRIORITY", NULL, FALSE); svSetValue (ifcfg, "IPV4_DNS_PRIORITY", NULL, FALSE);
success = TRUE; return TRUE;
out:
if (fake_ip4)
g_object_unref (s_ip4);
return success;
} }
static void static void