]> git.ipfire.org Git - thirdparty/libvirt.git/commit
remote_daemon_dispatch.c: typecast ARRAY_CARDINALITY() in remoteDispatchProbeURI()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 14 Aug 2019 12:41:42 +0000 (14:41 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 16 Aug 2019 06:56:02 +0000 (08:56 +0200)
commit3b7c5ab983f4655ae02b8af4517d89839530ee5f
treeb8b3130c4a22dd0428ba0d752d3bc4f35c6284da
parent459f071cacf30af9df93b7d090b1bda71b0ef20f
remote_daemon_dispatch.c: typecast ARRAY_CARDINALITY() in remoteDispatchProbeURI()

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@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
src/remote/remote_daemon_dispatch.c