]> xenbits.xensource.com Git - libvirt.git/commitdiff
udevProcessStorage: trim all whitespace from model and vendor
authorJán Tomko <jtomko@redhat.com>
Fri, 3 Jun 2016 17:33:05 +0000 (19:33 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 7 Jun 2016 10:53:37 +0000 (12:53 +0200)
Use virTrimSpaces instead of a custom implementation.

src/node_device/node_device_udev.c

index 84bea5040e4ed37344bbc8828305922706989e5f..1529c5a33bce7b52a131477acd50adcef085aa14 100644 (file)
@@ -839,20 +839,6 @@ static int udevKludgeStorageType(virNodeDeviceDefPtr def)
 }
 
 
-static void udevStripSpaces(char *s)
-{
-    if (s == NULL)
-        return;
-
-    while (virFileStripSuffix(s, " ")) {
-        /* do nothing */
-        ;
-    }
-
-    return;
-}
-
-
 static int udevProcessStorage(struct udev_device *device,
                               virNodeDeviceDefPtr def)
 {
@@ -876,10 +862,13 @@ static int udevProcessStorage(struct udev_device *device,
 
     if (udevGetStringSysfsAttr(device, "device/vendor", &data->storage.vendor) < 0)
         goto out;
-    udevStripSpaces(def->caps->data.storage.vendor);
+    if (def->caps->data.storage.vendor)
+        virTrimSpaces(def->caps->data.storage.vendor, NULL);
+
     if (udevGetStringSysfsAttr(device, "device/model", &data->storage.model) < 0)
         goto out;
-    udevStripSpaces(def->caps->data.storage.model);
+    if (def->caps->data.storage.model)
+        virTrimSpaces(def->caps->data.storage.model, NULL);
     /* There is no equivalent of the hotpluggable property in libudev,
      * but storage is going toward a world in which hotpluggable is
      * expected, so I don't see a problem with not having a property