mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
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:
parent
34851dd8f4
commit
9013204afe
@ -412,13 +412,13 @@ virNetworkDHCPLeaseTimeDefParseXML(virNetworkDHCPLeaseTimeDef **lease,
|
|||||||
virNetworkDHCPLeaseTimeDef *new_lease = NULL;
|
virNetworkDHCPLeaseTimeDef *new_lease = NULL;
|
||||||
g_autofree char *expirystr = NULL;
|
g_autofree char *expirystr = NULL;
|
||||||
g_autofree char *unitstr = NULL;
|
g_autofree char *unitstr = NULL;
|
||||||
unsigned long expiry;
|
unsigned long long expiry;
|
||||||
int unit = VIR_NETWORK_DHCP_LEASETIME_UNIT_MINUTES;
|
int unit = VIR_NETWORK_DHCP_LEASETIME_UNIT_MINUTES;
|
||||||
|
|
||||||
if (!(expirystr = virXMLPropString(node, "expiry")))
|
if (!(expirystr = virXMLPropString(node, "expiry")))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (virStrToLong_ul(expirystr, NULL, 10, &expiry) < 0) {
|
if (virStrToLong_ull(expirystr, NULL, 10, &expiry) < 0) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("failed to parse expiry value '%s'"), expirystr);
|
_("failed to parse expiry value '%s'"), expirystr);
|
||||||
return -1;
|
return -1;
|
||||||
@ -2312,7 +2312,7 @@ virNetworkIPDefFormat(virBuffer *buf,
|
|||||||
if (!lease->expiry) {
|
if (!lease->expiry) {
|
||||||
virBufferAddLit(buf, "<lease expiry='0'/>\n");
|
virBufferAddLit(buf, "<lease expiry='0'/>\n");
|
||||||
} else {
|
} else {
|
||||||
virBufferAsprintf(buf, "<lease expiry='%lu' unit='%s'/>\n",
|
virBufferAsprintf(buf, "<lease expiry='%llu' unit='%s'/>\n",
|
||||||
lease->expiry,
|
lease->expiry,
|
||||||
virNetworkDHCPLeaseTimeUnitTypeToString(lease->unit));
|
virNetworkDHCPLeaseTimeUnitTypeToString(lease->unit));
|
||||||
}
|
}
|
||||||
@ -2344,7 +2344,7 @@ virNetworkIPDefFormat(virBuffer *buf,
|
|||||||
if (!lease->expiry) {
|
if (!lease->expiry) {
|
||||||
virBufferAddLit(buf, "<lease expiry='0'/>\n");
|
virBufferAddLit(buf, "<lease expiry='0'/>\n");
|
||||||
} else {
|
} else {
|
||||||
virBufferAsprintf(buf, "<lease expiry='%lu' unit='%s'/>\n",
|
virBufferAsprintf(buf, "<lease expiry='%llu' unit='%s'/>\n",
|
||||||
lease->expiry,
|
lease->expiry,
|
||||||
virNetworkDHCPLeaseTimeUnitTypeToString(lease->unit));
|
virNetworkDHCPLeaseTimeUnitTypeToString(lease->unit));
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ VIR_ENUM_DECL(virNetworkForwardDriverName);
|
|||||||
|
|
||||||
typedef struct _virNetworkDHCPLeaseTimeDef virNetworkDHCPLeaseTimeDef;
|
typedef struct _virNetworkDHCPLeaseTimeDef virNetworkDHCPLeaseTimeDef;
|
||||||
struct _virNetworkDHCPLeaseTimeDef {
|
struct _virNetworkDHCPLeaseTimeDef {
|
||||||
unsigned long expiry;
|
unsigned long long expiry;
|
||||||
virNetworkDHCPLeaseTimeUnitType unit;
|
virNetworkDHCPLeaseTimeUnitType unit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -988,7 +988,7 @@ networkBuildDnsmasqLeaseTime(virNetworkDHCPLeaseTimeDef *lease)
|
|||||||
} else {
|
} else {
|
||||||
unit = virNetworkDHCPLeaseTimeUnitTypeToString(lease->unit);
|
unit = virNetworkDHCPLeaseTimeUnitTypeToString(lease->unit);
|
||||||
/* We get only first compatible char from string: 's', 'm' or 'h' */
|
/* 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);
|
return virBufferContentAndReset(&buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user