[libvirt] [PATCH 15/32] udevProcessFloppy; remove unnecessary allocation

Ján Tomko jtomko at redhat.com
Mon Jun 6 09:01:52 UTC 2016


Use udevHasDeviceProperty instead of udevGetStringProperty.
We do not need to copy the string since we do not need it.

Also add braces around the if body, since the change made
syntax check complain.
---
 src/node_device/node_device_udev.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index d7a49f8..46e48df 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -892,17 +892,14 @@ static int udevProcessFloppy(struct udev_device *device,
 {
     int tmp_int = 0;
     int has_media = 0;
-    char *tmp_str = NULL;
 
     if ((udevGetIntProperty(device, "DKD_MEDIA_AVAILABLE",
-                            &tmp_int, 0) == PROPERTY_FOUND))
+                            &tmp_int, 0) == PROPERTY_FOUND)) {
         /* USB floppy */
         has_media = tmp_int;
-    else if (udevGetStringProperty(device, "ID_FS_LABEL",
-                                   &tmp_str) == PROPERTY_FOUND) {
+    } else if (udevHasDeviceProperty(device, "ID_FS_LABEL")) {
         /* Legacy floppy */
         has_media = 1;
-        VIR_FREE(tmp_str);
     }
 
     return udevProcessRemoveableMedia(device, def, has_media);
-- 
2.7.3




More information about the libvir-list mailing list