[libvirt] [PATCH] remote_daemon_dispatch.c: typecast ARRAY_CARDINALITY() in remoteDispatchProbeURI()

Jim Fehlig JFEHLIG at suse.com
Thu Aug 15 19:32:43 UTC 2019


On 8/14/19 7:13 AM, Michal Privoznik wrote:
> Since users can enable/disable drivers at compile time, it may
> happen that @drivers array is in fact empty (in both its
> occurrences within the function). This means that
> ARRAY_CARDINALITY() returns 0UL which makes gcc unhappy because
> of loop condition:
> 
>    i < ARRAY_CARDINALITY(drivers)
> 
> GCC complains that @i is unsigned and comparing an unsigned value
> against 0 is always false. However, changing the type of @i to
> ssize_t is not enough, because compiler still sees the unsigned
> zero. The solution is to typecast the ARRAY_CARDINALITY().
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>   src/remote/remote_daemon_dispatch.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

Typing the original mail and reviewing and testing this patch probably took 
longer than fixing it in the first place :-). Thanks for taking care of it!

Reviewed-by: Jim Fehlig <jfehlig at suse.com>

Regards,
Jim




More information about the libvir-list mailing list