qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 7/7] libvhost-user: Switch to unsigned int for inuse field in struct VuVirtq
@ 2022-12-19 17:53 Marcel Holtmann
  2022-12-19 18:37 ` Philippe Mathieu-Daudé
  2022-12-20 15:15 ` Michael S. Tsirkin
  0 siblings, 2 replies; 5+ messages in thread
From: Marcel Holtmann @ 2022-12-19 17:53 UTC (permalink / raw)
  To: qemu-devel, mst; +Cc: marcel

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;
 
     vu_queue_handler_cb handler;
 
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-20 19:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-19 17:53 [PATCH 7/7] libvhost-user: Switch to unsigned int for inuse field in struct VuVirtq Marcel Holtmann
2022-12-19 18:37 ` Philippe Mathieu-Daudé
2022-12-19 18:58   ` Marcel Holtmann
2022-12-20 15:15 ` Michael S. Tsirkin
2022-12-20 19:04   ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).