qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 7/7] libvhost-user: Switch to unsigned int for inuse field in


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 7/7] libvhost-user: Switch to unsigned int for inuse field in struct VuVirtq
Date: Mon, 19 Dec 2022 19:37:57 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.1

On 19/12/22 18:53, Marcel Holtmann wrote:
It seems there is no need to keep the inuse field signed and end up with
compiler warnings for sign-compare.

   CC       libvhost-user.o
libvhost-user.c: In function ‘vu_queue_pop’:
libvhost-user.c:2763:19: error: comparison of integer expressions of different 
signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  2763 |     if (vq->inuse >= vq->vring.num) {
       |                   ^~
libvhost-user.c: In function ‘vu_queue_rewind’:
libvhost-user.c:2808:13: error: comparison of integer expressions of different 
signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
  2808 |     if (num > vq->inuse) {
       |             ^

Instead of casting the comparision to unsigned int, just make the inuse
field unsigned int in the fist place.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
  subprojects/libvhost-user/libvhost-user.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subprojects/libvhost-user/libvhost-user.h 
b/subprojects/libvhost-user/libvhost-user.h
index aea7ec5061d5..8cda9b8f577a 100644
--- a/subprojects/libvhost-user/libvhost-user.h
+++ b/subprojects/libvhost-user/libvhost-user.h
@@ -343,7 +343,7 @@ typedef struct VuVirtq {
      /* Notification enabled? */
      bool notification;
- int inuse;
+    unsigned int inuse;

Another use in subprojects/libvduse/libvduse.c.

Possibly both could be renamed refcount which is more meaningful.

Anyhow,
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




reply via email to

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