summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-02-01 12:10:20 +0100
committerBastien Nocera <hadess@hadess.net>2021-02-04 09:45:50 +0000
commit4b96535023d5bdbc6df0b81b9e6e315e47ceb8a8 (patch)
tree202211772f8a7c45e8fbdaf8f957645c3e6b0e3f
parent8e5b1d6b4652c5144ca5dfc768997a53a46a7ad1 (diff)
up-client: Document and handle NULL return when getting devices
-rw-r--r--libupower-glib/up-client.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c
index 26a6af7..723ab75 100644
--- a/libupower-glib/up-client.c
+++ b/libupower-glib/up-client.c
@@ -82,7 +82,7 @@ G_DEFINE_TYPE_WITH_CODE (UpClient, up_client, G_TYPE_OBJECT,
* function for the #GPtrArray so you need use g_object_unref on all
* elements when you are finished with the array.
*
- * Return value: (element-type UpDevice) (transfer full): an array of #UpDevice objects, free with g_ptr_array_unref()
+ * Return value: (element-type UpDevice) (transfer full): an array of #UpDevice objects or %NULL on error, free with g_ptr_array_unref()
*
* Since: 0.9.0
* Deprecated: 0.99.8
@@ -91,7 +91,8 @@ GPtrArray *
up_client_get_devices (UpClient *client)
{
GPtrArray *array = up_client_get_devices2 (client);
- g_ptr_array_set_free_func (array, NULL);
+ if (array)
+ g_ptr_array_set_free_func (array, NULL);
return array;
}
@@ -101,7 +102,7 @@ up_client_get_devices (UpClient *client)
*
* Get a copy of the device objects.
*
- * Return value: (element-type UpDevice) (transfer full): an array of #UpDevice objects, free with g_ptr_array_unref()
+ * Return value: (element-type UpDevice) (transfer full): an array of #UpDevice objects or %NULL on error, free with g_ptr_array_unref()
*
* Since: 0.99.8
**/