virNetworkDHCPLeaseTimeDef: Make expiry unsigned long long

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>
This commit is contained in:
Tim Wiederhake 2021-05-10 14:48:34 +02:00 committed by Michal Privoznik
parent 34851dd8f4
commit 9013204afe
3 changed files with 6 additions and 6 deletions

View 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));
}

View File

@ -105,7 +105,7 @@ VIR_ENUM_DECL(virNetworkForwardDriverName);
typedef struct _virNetworkDHCPLeaseTimeDef virNetworkDHCPLeaseTimeDef;
struct _virNetworkDHCPLeaseTimeDef {
unsigned long expiry;
unsigned long long expiry;
virNetworkDHCPLeaseTimeUnitType unit;
};

View 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);