]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virNetworkDHCPLeaseTimeDef: Make expiry unsigned long long
authorTim Wiederhake <twiederh@redhat.com>
Mon, 10 May 2021 12:48:34 +0000 (14:48 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 11 May 2021 12:03:44 +0000 (14:03 +0200)
The width of `unsigned long` differs on 32 bit and 64 bit architectures.
There is no compelling reason why the maximum DHCP lease time should
depend on the architecture.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/network_conf.c
src/conf/network_conf.h
src/network/bridge_driver.c

index d6eafa3f575c06d9358ffa3a2976317a06f161a3..c3c335135b594bc1639f2cb10f7ae562606201eb 100644 (file)
@@ -412,13 +412,13 @@ virNetworkDHCPLeaseTimeDefParseXML(virNetworkDHCPLeaseTimeDef **lease,
     virNetworkDHCPLeaseTimeDef *new_lease = NULL;
     g_autofree char *expirystr = NULL;
     g_autofree char *unitstr = NULL;
-    unsigned long expiry;
+    unsigned long long expiry;
     int unit = VIR_NETWORK_DHCP_LEASETIME_UNIT_MINUTES;
 
     if (!(expirystr = virXMLPropString(node, "expiry")))
         return 0;
 
-    if (virStrToLong_ul(expirystr, NULL, 10, &expiry) < 0) {
+    if (virStrToLong_ull(expirystr, NULL, 10, &expiry) < 0) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("failed to parse expiry value '%s'"), expirystr);
         return -1;
@@ -2312,7 +2312,7 @@ virNetworkIPDefFormat(virBuffer *buf,
                 if (!lease->expiry) {
                     virBufferAddLit(buf, "<lease expiry='0'/>\n");
                 } else {
-                    virBufferAsprintf(buf, "<lease expiry='%lu' unit='%s'/>\n",
+                    virBufferAsprintf(buf, "<lease expiry='%llu' unit='%s'/>\n",
                                       lease->expiry,
                                       virNetworkDHCPLeaseTimeUnitTypeToString(lease->unit));
                 }
@@ -2344,7 +2344,7 @@ virNetworkIPDefFormat(virBuffer *buf,
                 if (!lease->expiry) {
                     virBufferAddLit(buf, "<lease expiry='0'/>\n");
                 } else {
-                    virBufferAsprintf(buf, "<lease expiry='%lu' unit='%s'/>\n",
+                    virBufferAsprintf(buf, "<lease expiry='%llu' unit='%s'/>\n",
                                       lease->expiry,
                                       virNetworkDHCPLeaseTimeUnitTypeToString(lease->unit));
                 }
index a7e6b7a2a6df19b2ec928e7fd812940f6e1dc220..6199f3f5885820aaebffc6057b125d7c04b60504 100644 (file)
@@ -105,7 +105,7 @@ VIR_ENUM_DECL(virNetworkForwardDriverName);
 
 typedef struct _virNetworkDHCPLeaseTimeDef virNetworkDHCPLeaseTimeDef;
 struct _virNetworkDHCPLeaseTimeDef {
-    unsigned long expiry;
+    unsigned long long expiry;
     virNetworkDHCPLeaseTimeUnitType unit;
 };
 
index ee3f9dab0af646403651f86f22b1e7bac3451935..a711b34c4833b4fbddbd7cc2ae9106f917107efd 100644 (file)
@@ -988,7 +988,7 @@ networkBuildDnsmasqLeaseTime(virNetworkDHCPLeaseTimeDef *lease)
     } else {
         unit = virNetworkDHCPLeaseTimeUnitTypeToString(lease->unit);
         /* We get only first compatible char from string: 's', 'm' or 'h' */
-        virBufferAsprintf(&buf, "%lu%c", lease->expiry, unit[0]);
+        virBufferAsprintf(&buf, "%llu%c", lease->expiry, unit[0]);
     }
 
     return virBufferContentAndReset(&buf);