diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index 497f6c36e3..2fbc4f1162 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -154,7 +154,7 @@ constructor (GType type, priv = NM_OBJECT_GET_PRIVATE (object); if (priv->connection == NULL || priv->path == NULL) { - g_warning ("%s: bus connection and path required.", __func__); + g_warn_if_reached (); g_object_unref (object); return NULL; } @@ -570,7 +570,7 @@ _nm_object_create (GType type, DBusGConnection *connection, const char *path) type = type_func (connection, path); if (type == G_TYPE_INVALID) { - g_warning ("Could not create object for %s: unknown object type", path); + dbgmsg ("Could not create object for %s: unknown object type", path); return NULL; } @@ -579,10 +579,9 @@ _nm_object_create (GType type, DBusGConnection *connection, const char *path) NM_OBJECT_DBUS_PATH, path, NULL); if (!g_initable_init (G_INITABLE (object), NULL, &error)) { - g_object_unref (object); - object = NULL; - g_warning ("Could not create object for %s: %s", path, error->message); + dbgmsg ("Could not create object for %s: %s", path, error->message); g_error_free (error); + g_clear_object (&object); } return object; @@ -624,13 +623,11 @@ async_inited (GObject *source, GAsyncResult *result, gpointer user_data) GError *error = NULL; if (!g_async_initable_init_finish (G_ASYNC_INITABLE (object), result, &error)) { - if (!g_error_matches (error, DBUS_GERROR, DBUS_GERROR_UNKNOWN_METHOD)) { - g_warning ("Could not create object for %s: %s", - nm_object_or_connection_get_path (object), error->message); - } + dbgmsg ("Could not create object for %s: %s", + nm_object_or_connection_get_path (object), + error->message); g_error_free (error); - g_object_unref (object); - object = NULL; + g_clear_object (&object); } create_async_complete (object, async_data); @@ -1028,10 +1025,10 @@ handle_property_changed (NMObject *self, const char *dbus_name, GValue *value, g pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (self)), prop_name); if (!pspec) { - g_warning ("%s: property '%s' changed but wasn't defined by object type %s.", - __func__, - prop_name, - G_OBJECT_TYPE_NAME (self)); + dbgmsg ("%s: property '%s' changed but wasn't defined by object type %s.", + __func__, + prop_name, + G_OBJECT_TYPE_NAME (self)); goto out; } @@ -1061,10 +1058,10 @@ handle_property_changed (NMObject *self, const char *dbus_name, GValue *value, g success = (*(pi->func)) (self, pspec, value, pi->field); if (!success) { - g_warning ("%s: failed to update property '%s' of object type %s.", - __func__, - prop_name, - G_OBJECT_TYPE_NAME (self)); + dbgmsg ("%s: failed to update property '%s' of object type %s.", + __func__, + prop_name, + G_OBJECT_TYPE_NAME (self)); } out: @@ -1086,8 +1083,8 @@ process_properties_changed (NMObject *self, GHashTable *properties, gboolean syn if (value) handle_property_changed (self, name, value, synchronously); else { - g_warning ("%s:%d %s(): object %s property '%s' value is unexpectedly NULL", - __FILE__, __LINE__, __func__, G_OBJECT_TYPE_NAME (self), (const char *) name); + dbgmsg ("%s:%d %s(): object %s property '%s' value is unexpectedly NULL", + __FILE__, __LINE__, __func__, G_OBJECT_TYPE_NAME (self), (const char *) name); } } } @@ -1147,9 +1144,11 @@ demarshal_generic (NMObject *object, HANDLE_TYPE(LONG, long, long) HANDLE_TYPE(ULONG, ulong, ulong) } else { - g_warning ("%s: %s/%s unhandled type %s.", - __func__, G_OBJECT_TYPE_NAME (object), pspec->name, - g_type_name (pspec->value_type)); + dbgmsg ("%s: %s/%s unhandled type %s.", + __func__, + G_OBJECT_TYPE_NAME (object), + pspec->name, + g_type_name (pspec->value_type)); success = FALSE; } @@ -1157,9 +1156,9 @@ done: if (success) { _nm_object_queue_notify (object, pspec->name); } else { - g_warning ("%s: %s/%s (type %s) couldn't be set with type %s.", - __func__, G_OBJECT_TYPE_NAME (object), pspec->name, - g_type_name (pspec->value_type), G_VALUE_TYPE_NAME (value)); + dbgmsg ("%s: %s/%s (type %s) couldn't be set with type %s.", + __func__, G_OBJECT_TYPE_NAME (object), pspec->name, + g_type_name (pspec->value_type), G_VALUE_TYPE_NAME (value)); } return success; } @@ -1258,9 +1257,10 @@ _nm_object_ensure_inited (NMObject *object) if (!priv->inited) { if (!g_initable_init (G_INITABLE (object), NULL, &error)) { - g_warning ("Could not initialize %s %s: %s", - G_OBJECT_TYPE_NAME (object), priv->path, - error->message); + dbgmsg ("Could not initialize %s %s: %s", + G_OBJECT_TYPE_NAME (object), + priv->path, + error->message); g_error_free (error); /* Only warn once */ @@ -1291,17 +1291,12 @@ _nm_object_reload_property (NMObject *object, G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { - /* Don't warn about D-Bus no reply/timeout errors; it's mostly noise and - * happens for example when NM quits and the applet is still running. - */ - if (!g_error_matches (err, DBUS_GERROR, DBUS_GERROR_NO_REPLY)) { - g_warning ("%s: Error getting '%s' for %s: (%d) %s\n", - __func__, - prop_name, - nm_object_get_path (object), - err->code, - err->message); - } + dbgmsg ("%s: Error getting '%s' for %s: (%d) %s\n", + __func__, + prop_name, + nm_object_get_path (object), + err->code, + err->message); g_clear_error (&err); return; }