* [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
* Re: [PATCH 7/7] libvhost-user: Switch to unsigned int for inuse field in struct VuVirtq
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
1 sibling, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-12-19 18:37 UTC (permalink / raw)
To: Marcel Holtmann, qemu-devel, mst; +Cc: Raphael Norwitz, Marc-André Lureau
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 7/7] libvhost-user: Switch to unsigned int for inuse field in struct VuVirtq
2022-12-19 18:37 ` Philippe Mathieu-Daudé
@ 2022-12-19 18:58 ` Marcel Holtmann
0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2022-12-19 18:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, mst, Raphael Norwitz, Marc-André Lureau
Hi Philippe,
>> 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.
I quickly tried libvduse.[ch] and it has clearly less warnings than
libvhost-user, but some things could be applied there as well.
I looks like only the _GNU_SOURCE and the unsigned int inuse are
applicable, but there is a strict-aliasing issue that I first have
to fully understand.
If patches are acceptable, I send them as well for libvduse.
Regards
Marcel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 7/7] libvhost-user: Switch to unsigned int for inuse field in struct VuVirtq
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-20 15:15 ` Michael S. Tsirkin
2022-12-20 19:04 ` Marcel Holtmann
1 sibling, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2022-12-20 15:15 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: qemu-devel
On Mon, Dec 19, 2022 at 06:53:37PM +0100, 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>
Is this a part of a patchset? No threading visible and I'd rather not
guess.
> ---
> 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 [flat|nested] 5+ messages in thread
* Re: [PATCH 7/7] libvhost-user: Switch to unsigned int for inuse field in struct VuVirtq
2022-12-20 15:15 ` Michael S. Tsirkin
@ 2022-12-20 19:04 ` Marcel Holtmann
0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2022-12-20 19:04 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
Hi Michael,
>> 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>
>
>
> Is this a part of a patchset? No threading visible and I'd rather not
> guess.
I am going to re-send both series as v2.
Regards
Marcel
^ permalink raw reply [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).