]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: selftests: Return an 'unsigned int' from kvm_check_cap()
authorSean Christopherson <seanjc@google.com>
Fri, 27 May 2022 22:09:52 +0000 (15:09 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 11 Jun 2022 15:47:27 +0000 (11:47 -0400)
Return an 'unsigned int' instead of a signed 'int' from kvm_check_cap(),
to make it more obvious that kvm_check_cap() can never return a negative
value due to its assertion that the return is ">= 0".

Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/include/kvm_util_base.h
tools/testing/selftests/kvm/kvm_binary_stats_test.c
tools/testing/selftests/kvm/lib/kvm_util.c

index 1c762988ab9c1498bde4a3fe8a73a0a0a9c8d977..72cc0ecda067bf9fb05b649d55089fb5812ad4e7 100644 (file)
@@ -167,7 +167,7 @@ extern const struct vm_guest_mode_params vm_guest_mode_params[];
 
 int open_path_or_exit(const char *path, int flags);
 int open_kvm_dev_path_or_exit(void);
-int kvm_check_cap(long cap);
+unsigned int kvm_check_cap(long cap);
 
 #define __KVM_SYSCALL_ERROR(_name, _ret) \
        "%s failed, rc: %i errno: %i (%s)", (_name), (_ret), errno, strerror(errno)
index 7f2ddc1535d700a0e69d7d626d3684eeea69b2f6..982bf3f7d9c54d3f89825242ac561917cad44608 100644 (file)
@@ -213,7 +213,7 @@ int main(int argc, char *argv[])
        }
 
        /* Check the extension for binary stats */
-       if (kvm_check_cap(KVM_CAP_BINARY_STATS_FD) <= 0) {
+       if (!kvm_check_cap(KVM_CAP_BINARY_STATS_FD)) {
                print_skip("Binary form statistics interface is not supported");
                exit(KSFT_SKIP);
        }
index 86e7f5afce631d04fb4de4995f146e3c7b84b161..4cf0e6bf33bb0ed18cbefb66c060809fc5fa342e 100644 (file)
@@ -69,7 +69,7 @@ int open_kvm_dev_path_or_exit(void)
  * Looks up and returns the value corresponding to the capability
  * (KVM_CAP_*) given by cap.
  */
-int kvm_check_cap(long cap)
+unsigned int kvm_check_cap(long cap)
 {
        int ret;
        int kvm_fd;