ifcfg-rh: remove "ignore_error" arg from connection_from_file()

Instead of having connection_from_file() return a flag telling its
caller whether to log a warning or not, just have it log the warning
(or not) itself.
This commit is contained in:
Dan Winship
2014-12-16 09:18:31 -05:00
parent 356849f70c
commit 12bfaf5a8d
5 changed files with 17 additions and 31 deletions

View File

@@ -102,8 +102,7 @@ files_changed_cb (NMInotifyHelper *ih,
NMIfcfgConnection * NMIfcfgConnection *
nm_ifcfg_connection_new (NMConnection *source, nm_ifcfg_connection_new (NMConnection *source,
const char *full_path, const char *full_path,
GError **error, GError **error)
gboolean *ignore_error)
{ {
GObject *object; GObject *object;
NMConnection *tmp; NMConnection *tmp;
@@ -119,8 +118,7 @@ nm_ifcfg_connection_new (NMConnection *source,
else { else {
tmp = connection_from_file (full_path, tmp = connection_from_file (full_path,
&unhandled_spec, &unhandled_spec,
error, error);
ignore_error);
if (!tmp) if (!tmp)
return NULL; return NULL;
@@ -259,7 +257,7 @@ commit_changes (NMSettingsConnection *connection,
* it if it's really changed. * it if it's really changed.
*/ */
if (priv->path) { if (priv->path) {
reread = connection_from_file (priv->path, NULL, NULL, NULL); reread = connection_from_file (priv->path, NULL, NULL);
if (reread) { if (reread) {
same = nm_connection_compare (NM_CONNECTION (connection), same = nm_connection_compare (NM_CONNECTION (connection),
reread, reread,

View File

@@ -48,8 +48,7 @@ GType nm_ifcfg_connection_get_type (void);
NMIfcfgConnection *nm_ifcfg_connection_new (NMConnection *source, NMIfcfgConnection *nm_ifcfg_connection_new (NMConnection *source,
const char *full_path, const char *full_path,
GError **error, GError **error);
gboolean *ignore_error);
const char *nm_ifcfg_connection_get_path (NMIfcfgConnection *self); const char *nm_ifcfg_connection_get_path (NMIfcfgConnection *self);

View File

@@ -129,23 +129,13 @@ _internal_new_connection (SCPluginIfcfg *self,
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self); SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
NMIfcfgConnection *connection; NMIfcfgConnection *connection;
const char *cid; const char *cid;
GError *local = NULL;
gboolean ignore_error = FALSE;
if (!source) if (!source)
nm_log_info (LOGD_SETTINGS, "parsing %s ... ", path); nm_log_info (LOGD_SETTINGS, "parsing %s ... ", path);
connection = nm_ifcfg_connection_new (source, path, &local, &ignore_error); connection = nm_ifcfg_connection_new (source, path, error);
if (!connection) { if (!connection)
if (!ignore_error)
nm_log_warn (LOGD_SETTINGS, " %s", (local && local->message) ? local->message : "(unknown)");
if (local)
g_propagate_error (error, local);
else
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"(unknown)");
return NULL; return NULL;
}
cid = nm_connection_get_id (NM_CONNECTION (connection)); cid = nm_connection_get_id (NM_CONNECTION (connection));
g_assert (cid); g_assert (cid);
@@ -248,7 +238,6 @@ connection_new_or_changed (SCPluginIfcfg *self,
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self); SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
NMIfcfgConnection *new; NMIfcfgConnection *new;
GError *error = NULL; GError *error = NULL;
gboolean ignore_error = FALSE;
const char *new_unmanaged = NULL, *old_unmanaged = NULL; const char *new_unmanaged = NULL, *old_unmanaged = NULL;
const char *new_unrecognized = NULL, *old_unrecognized = NULL; const char *new_unrecognized = NULL, *old_unrecognized = NULL;
gboolean unmanaged_changed, unrecognized_changed; gboolean unmanaged_changed, unrecognized_changed;
@@ -285,13 +274,9 @@ connection_new_or_changed (SCPluginIfcfg *self,
return; return;
} }
new = (NMIfcfgConnection *) nm_ifcfg_connection_new (NULL, path, &error, &ignore_error); new = (NMIfcfgConnection *) nm_ifcfg_connection_new (NULL, path, NULL);
if (!new) { if (!new) {
/* errors reading connection; remove it */ /* errors reading connection; remove it */
if (!ignore_error)
nm_log_warn (LOGD_SETTINGS, " %s", (error && error->message) ? error->message : "(unknown)");
g_clear_error (&error);
nm_log_info (LOGD_SETTINGS, "removed %s.", path); nm_log_info (LOGD_SETTINGS, "removed %s.", path);
remove_connection (self, existing); remove_connection (self, existing);
return; return;

View File

@@ -4842,14 +4842,19 @@ done:
NMConnection * NMConnection *
connection_from_file (const char *filename, connection_from_file (const char *filename,
char **out_unhandled, char **out_unhandled,
GError **error, GError **error)
gboolean *out_ignore_error)
{ {
return connection_from_file_full (filename, NULL, NULL, gboolean ignore_error = FALSE;
NMConnection *conn;
conn = connection_from_file_full (filename, NULL, NULL,
out_unhandled, out_unhandled,
NULL, NULL, NULL, NULL, NULL, NULL,
error, error,
out_ignore_error); &ignore_error);
if (error && *error && !ignore_error)
PARSE_WARNING ("%s", (*error)->message);
return conn;
} }
NMConnection * NMConnection *

View File

@@ -28,8 +28,7 @@
NMConnection *connection_from_file (const char *filename, NMConnection *connection_from_file (const char *filename,
char **out_unhandled, char **out_unhandled,
GError **error, GError **error);
gboolean *out_ignore_error);
char *uuid_from_file (const char *filename); char *uuid_from_file (const char *filename);