summaryrefslogtreecommitdiff
path: root/metadata
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2018-04-12 13:12:37 +0200
committerOndrej Holy <oholy@redhat.com>2018-04-13 10:14:16 +0200
commitd7e1397854f32e793b4f65d894908d67072dcb3f (patch)
treefb437696c67413b3f01e1dd8bf6298eafd64a25c /metadata
parentd47e70ec0e80296a20aa42fc9fbade37235c1c75 (diff)
downloadgvfs-d7e1397854f32e793b4f65d894908d67072dcb3f.tar.gz
metadata: Prevent usage of NULL if GUdevDevice is not found
Code to determine tree name from device has been recently ported from udev to gudev by commit c2d8564. Unfortunately, the gudev code floods logs by the following messages if device is not found (it can happen e.g. for tmpfs): g_udev_device_has_property: assertion 'G_UDEV_IS_DEVICE (device)' failed Udev code silently returned if NULL device was used, however, corresponding gudev code prints the mentioned messages. Let's prevent usage of NULL device in order to prevent those messages. https://bugzilla.gnome.org/show_bug.cgi?id=795191
Diffstat (limited to 'metadata')
-rw-r--r--metadata/meta-daemon.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/metadata/meta-daemon.c b/metadata/meta-daemon.c
index 444a4394..26edfcb3 100644
--- a/metadata/meta-daemon.c
+++ b/metadata/meta-daemon.c
@@ -319,13 +319,15 @@ handle_get_tree_from_device (GVfsMetadata *object,
g_once_init_leave (&gudev_client, g_udev_client_new (NULL));
device = g_udev_client_query_by_device_number (gudev_client, G_UDEV_DEVICE_TYPE_BLOCK, devnum);
+ if (device != NULL)
+ {
+ if (g_udev_device_has_property (device, "ID_FS_UUID_ENC"))
+ res = g_strconcat ("uuid-", g_udev_device_get_property (device, "ID_FS_UUID_ENC"), NULL);
+ else if (g_udev_device_has_property (device, "ID_FS_LABEL_ENC"))
+ res = g_strconcat ("label-", g_udev_device_get_property (device, "ID_FS_LABEL_ENC"), NULL);
- if (g_udev_device_has_property (device, "ID_FS_UUID_ENC"))
- res = g_strconcat ("uuid-", g_udev_device_get_property (device, "ID_FS_UUID_ENC"), NULL);
- else if (g_udev_device_has_property (device, "ID_FS_LABEL_ENC"))
- res = g_strconcat ("label-", g_udev_device_get_property (device, "ID_FS_LABEL_ENC"), NULL);
-
- g_clear_object (&device);
+ g_clear_object (&device);
+ }
#endif
gvfs_metadata_complete_get_tree_from_device (object, invocation, res ? res : "");