mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-31 18:15:25 +00:00
virconf: skip some range checks if SSIZE_MAX >= LLONG_MAX
If size_t is the same size as long long, then we can skip some of the range checks. This avoids triggering some bogus compiler warning messages. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
10932015d4
commit
fe8bad38f5
@ -1216,12 +1216,14 @@ int virConfGetValueSizeT(virConfPtr conf,
|
||||
return -1;
|
||||
}
|
||||
} else if (cval->type == VIR_CONF_ULONG) {
|
||||
#if ULLONG_MAX > SIZE_MAX
|
||||
if (((unsigned long long)cval->l) > SIZE_MAX) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: value for '%s' parameter must be in range 0:%zu"),
|
||||
conf->filename, setting, SIZE_MAX);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: expected an unsigned integer for '%s' parameter"),
|
||||
@ -1271,12 +1273,14 @@ int virConfGetValueSSizeT(virConfPtr conf,
|
||||
return -1;
|
||||
}
|
||||
} else if (cval->type == VIR_CONF_LONG) {
|
||||
#if SSIZE_MAX < LLONG_MAX
|
||||
if (cval->l < (-SSIZE_MAX - 1) || cval->l > SSIZE_MAX) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: value for '%s' parameter must be in range %zd:%zd"),
|
||||
conf->filename, setting, (ssize_t)-SSIZE_MAX - 1, (ssize_t)SSIZE_MAX);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: expected a signed integer for '%s' parameter"),
|
||||
|
Loading…
Reference in New Issue
Block a user