Re: [PATCH] virconf: skip some range checks if SSIZE_MAX >= LLONG_MAX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 14.07.2016 12:30, Daniel P. Berrange wrote:
> 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@xxxxxxxxxx>
> ---
>  src/util/virconf.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/util/virconf.c b/src/util/virconf.c
> index f82d114..4813419 100644
> --- a/src/util/virconf.c
> +++ b/src/util/virconf.c
> @@ -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_MAX - 1, SSIZE_MAX);
>              return -1;
>          }
> +#endif
>      } else {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("%s: expected a signed integer for '%s' parameter"),
> 

ACK

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]