diff mbox series

[v2] qtest: fix 'expression is always false' build failure in qtest_has_accel()

Message ID 20211027151012.2639284-1-imammedo@redhat.com (mailing list archive)
State New, archived
Headers show
Series [v2] qtest: fix 'expression is always false' build failure in qtest_has_accel() | expand

Commit Message

Igor Mammedov Oct. 27, 2021, 3:10 p.m. UTC
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 making sure that CONFIG_KVM_TARGETS isn't empty.

Fixes: e741aff0f43343 ("tests: qtest: add qtest_has_accel() to check if tested binary supports accelerator")
Reported-by: Jason Andryuk <jandryuk@gmail.com>
Suggested-by: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jason Andryuk Oct. 27, 2021, 3:26 p.m. UTC | #1
On Wed, Oct 27, 2021 at 11:10 AM Igor Mammedov <imammedo@redhat.com> wrote:
>
> 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 making sure that CONFIG_KVM_TARGETS isn't empty.
>
> Fixes: e741aff0f43343 ("tests: qtest: add qtest_has_accel() to check if tested binary supports accelerator")
> Reported-by: Jason Andryuk <jandryuk@gmail.com>
> Suggested-by: "Michael S. Tsirkin" <mst@redhat.com>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Tested-by: Jason Andryuk <jandryuk@gmail.com>

Thanks,
Jason
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index 2c5b53cbe2..ff85e9c2af 100644
--- a/meson.build
+++ b/meson.build
@@ -75,7 +75,7 @@  else
   kvm_targets = []
 endif
 
-kvm_targets_c = ''
+kvm_targets_c = '""'
 if not get_option('kvm').disabled() and targetos == 'linux'
   kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
 endif