提交 3b7c5ab9 编写于 作者: M Michal Privoznik

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: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJim Fehlig <jfehlig@suse.com>
上级 459f071c
......@@ -2141,9 +2141,9 @@ remoteDispatchProbeURI(bool readonly,
"vbox",
# endif
};
size_t i;
ssize_t i;
for (i = 0; i < ARRAY_CARDINALITY(drivers) && !*probeduri; i++) {
for (i = 0; i < (ssize_t) ARRAY_CARDINALITY(drivers) && !*probeduri; i++) {
VIR_AUTOFREE(char *) daemonname = NULL;
VIR_AUTOFREE(char *) daemonpath = NULL;
......@@ -2187,9 +2187,9 @@ remoteDispatchProbeURI(bool readonly,
"vz",
# endif
};
size_t i;
ssize_t i;
for (i = 0; i < ARRAY_CARDINALITY(drivers) && !*probeduri; i++) {
for (i = 0; i < (ssize_t) ARRAY_CARDINALITY(drivers) && !*probeduri; i++) {
VIR_AUTOFREE(char *) sockname = NULL;
if (virAsprintf(&sockname, "%s/run/libvirt/virt%sd-%s",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册