qemu-devel
[Top][All Lists]
Advanced

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

[PATCH] qtest: fix 'expression is always false' build failure in qtest_h


From: Igor Mammedov
Subject: [PATCH] qtest: fix 'expression is always false' build failure in qtest_has_accel()
Date: Wed, 27 Oct 2021 03:45:42 -0400

If KVM is disabled or not present, qtest library build
may fail with:
   libqtest.c: In function 'qtest_has_accel':
      comparison of unsigned expression < 0 is always false
      [-Werror=type-limits]
         for (i = 0; i < ARRAY_SIZE(targets); i++) {

due to empty 'targets' array.
Fix it by compiling KVM related part only if
CONFIG_KVM_TARGETS is set.

Fixes: e741aff0f43343 ("tests: qtest: add qtest_has_accel() to check if tested 
binary supports accelerator")
Reported-by: Jason Andryuk <jandryuk@gmail.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 tests/qtest/libqtest.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 25aeea385b..9833e16f84 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -931,6 +931,7 @@ bool qtest_has_accel(const char *accel_name)
         return false;
 #endif
     } else if (g_str_equal(accel_name, "kvm")) {
+#if defined(CONFIG_KVM_TARGETS)
         int i;
         const char *arch = qtest_get_arch();
         const char *targets[] = { CONFIG_KVM_TARGETS };
@@ -942,6 +943,9 @@ bool qtest_has_accel(const char *accel_name)
                 }
             }
         }
+#else
+        return false;
+#endif
     } else {
         /* not implemented */
         g_assert_not_reached();
-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]