public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Yumei Huang <yuhuang@redhat.com>
Subject: Re: [PATCH] tcp: Avoid comparison of expressions with different signedness in tcp_timer_handler()
Date: Thu, 5 Mar 2026 13:20:22 +1100	[thread overview]
Message-ID: <aajoZpp97iq_VTd_@zatzit> (raw)
In-Reply-To: <20260304163203.2440767-1-sbrivio@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2280 bytes --]

On Wed, Mar 04, 2026 at 05:32:03PM +0100, Stefano Brivio wrote:
> With gcc 14.2, building against musl 1.2.5 (slightly outdated Alpine
> on x86_64):
> 
> tcp.c: In function 'tcp_timer_handler':
> util.h:40:39: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
>    40 | #define MIN(x, y)               (((x) < (y)) ? (x) : (y))
>       |                                       ^
> tcp.c:2593:31: note: in expansion of macro 'MIN'
>  2593 |                         max = MIN(TCP_MAX_RETRIES, max);
>       |                               ^~~
> util.h:40:54: warning: operand of '?:' changes signedness from 'int' to 'unsigned int' due to unsignedness of other operand [-Wsign-compare]
>    40 | #define MIN(x, y)               (((x) < (y)) ? (x) : (y))
>       |                                                      ^~~
> tcp.c:2593:31: note: in expansion of macro 'MIN'
>  2593 |                         max = MIN(TCP_MAX_RETRIES, max);
>       |                               ^~~
> 
> for some reason, that's not reported by gcc with glibc.
> 
> Make the temporary 'max' variable unsigned, as we know it can't be
> negative anyway.
> 
> While at it, add the customary blank line between variable
> declarations and code.
> 
> Fixes: 3dde0e07804e ("tcp: Update data retransmission timeout")
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  tcp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tcp.c b/tcp.c
> index 88ad886..68c92da 100644
> --- a/tcp.c
> +++ b/tcp.c
> @@ -2588,7 +2588,8 @@ void tcp_timer_handler(const struct ctx *c, union epoll_ref ref)
>  		tcp_timer_ctl(c, conn);
>  	} else if (conn->flags & ACK_FROM_TAP_DUE) {
>  		if (!(conn->events & ESTABLISHED)) {
> -			int max;
> +			unsigned int max;
> +
>  			max = c->tcp.syn_retries + c->tcp.syn_linear_timeouts;
>  			max = MIN(TCP_MAX_RETRIES, max);
>  			if (conn->retries >= max) {
> -- 
> 2.43.0
> 

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2026-03-05  2:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04 16:32 Stefano Brivio
2026-03-05  2:20 ` David Gibson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aajoZpp97iq_VTd_@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    --cc=yuhuang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).