]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virlease: Use virTrimSpaces() instead of open coded alternative
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Dec 2020 15:09:10 +0000 (16:09 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 4 Jan 2021 14:33:31 +0000 (15:33 +0100)
In virLeaseNew() we are trying to remove trailing space (per
comment it may happen that older versions of dnsmasq put it into
an env variable). Well, instead of open coding it, we can use
virTrimSpaces().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virlease.c

index f01cf5b9bdbfd6aa0c127daeb121e616e541adb0..edfdc6477aeafe1a30c0edb2f01e4b22f7dd79cb 100644 (file)
@@ -226,8 +226,7 @@ virLeaseNew(virJSONValuePtr *lease_ret,
 
         /* Removed extraneous trailing space in DNSMASQ_LEASE_EXPIRES
          * (dnsmasq < 2.52) */
-        if (exptime[strlen(exptime) - 1] == ' ')
-            exptime[strlen(exptime) - 1] = '\0';
+        virTrimSpaces(exptime, NULL);
     }
 
     if (!exptime ||