Skip to content

Commit

Permalink
dbus: do not fail on dbus object creation failures
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomaschewski committed Apr 10, 2014
1 parent 87140f2 commit 5dac78d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/dbus-object.c
Expand Up @@ -301,7 +301,7 @@ ni_dbus_object_get_service(const ni_dbus_object_t *object, const char *interface
const ni_dbus_service_t *svc;
unsigned int i;

if (object->interfaces == NULL)
if (object == NULL || object->interfaces == NULL)
return NULL;

for (i = 0; (svc = object->interfaces[i]) != NULL; ++i) {
Expand Down Expand Up @@ -364,7 +364,7 @@ ni_dbus_object_get_all_services_for_method(const ni_dbus_object_t *object, const
const ni_dbus_service_t *svc;
unsigned int i, found = 0;

if (object->interfaces == NULL || method == NULL)
if (object == NULL || object->interfaces == NULL || method == NULL)
return 0;

for (i = 0; (svc = object->interfaces[i]) != NULL; ++i) {
Expand All @@ -383,7 +383,7 @@ ni_dbus_object_get_service_for_signal(const ni_dbus_object_t *object, const char
const ni_dbus_service_t *svc, *best = NULL;
unsigned int i;

if (object->interfaces == NULL)
if (object == NULL || object->interfaces == NULL)
return NULL;

for (i = 0; (svc = object->interfaces[i]) != NULL; ++i) {
Expand All @@ -404,7 +404,7 @@ ni_dbus_object_get_service_for_property(const ni_dbus_object_t *object, const ch
const ni_dbus_service_t *svc;
unsigned int i;

if (object->interfaces == NULL)
if (object == NULL || object->interfaces == NULL)
return NULL;

for (i = 0; (svc = object->interfaces[i]) != NULL; ++i) {
Expand Down
16 changes: 13 additions & 3 deletions src/dbus-objects/interface.c
Expand Up @@ -374,8 +374,10 @@ __ni_objectmodel_build_netif_object(ni_dbus_server_t *server, ni_netdev_t *dev,
object = ni_dbus_object_new(class, NULL, ni_netdev_get(dev));
}

if (object == NULL)
ni_fatal("Unable to create dbus object for network interface %s", dev->name);
if (object == NULL) {
ni_error("Unable to create dbus object for network interface %s", dev->name);
return NULL;
}

ni_objectmodel_bind_compatible_interfaces(object);
return object;
Expand Down Expand Up @@ -504,8 +506,16 @@ ni_objectmodel_wrap_netif_request(ni_netdev_req_t *req)
ni_netdev_t *
ni_objectmodel_unwrap_netif(const ni_dbus_object_t *object, DBusError *error)
{
ni_netdev_t *dev = object->handle;
ni_netdev_t *dev;

if (!object) {
if (error)
dbus_set_error(error, DBUS_ERROR_FAILED,
"Cannot unwrap network interface from a NULL dbus object");
return NULL;
}

dev = object->handle;
if (ni_dbus_object_isa(object, &ni_objectmodel_netif_class))
return dev;
if (error)
Expand Down
17 changes: 14 additions & 3 deletions src/dbus-objects/modem.c
Expand Up @@ -198,8 +198,11 @@ __ni_objectmodel_build_modem_object(ni_dbus_server_t *server, ni_modem_t *modem)
object = ni_dbus_object_new(class, NULL, ni_modem_hold(modem));
}

if (object == NULL)
ni_fatal("Unable to create proxy object for modem %s (%s)", modem->device, modem->real_path);
if (object == NULL) {
ni_error("Unable to create proxy object for modem %s (%s)",
modem->device, modem->real_path);
return NULL;
}

ni_objectmodel_bind_compatible_interfaces(object);
return object;
Expand Down Expand Up @@ -262,8 +265,16 @@ ni_objectmodel_modem_full_path(const ni_modem_t *modem)
ni_modem_t *
ni_objectmodel_unwrap_modem(const ni_dbus_object_t *object, DBusError *error)
{
ni_modem_t *modem = object->handle;
ni_modem_t *modem;

if (!object) {
if (error)
dbus_set_error(error, DBUS_ERROR_FAILED,
"Cannot unwrap modem from a NULL dbus object");
return NULL;
}

modem = object->handle;
if (ni_dbus_object_isa(object, &ni_objectmodel_mm_modem_class))
return modem;
if (ni_dbus_object_isa(object, &ni_objectmodel_modem_class))
Expand Down

0 comments on commit 5dac78d

Please sign in to comment.