From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=V8SuFtHo; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 0A8B05A0269 for ; Thu, 05 Mar 2026 03:32:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1772677934; bh=DSycsG9BnrUUBhgNOwKLBjduyz8SQCvSygzvzBgo5ZA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V8SuFtHoG8QfVjEqysAgujtZau1VHVdh0BPYWhEx3S8/oTknhrfrOfVVkws/aKinr 1HO7VvR7JDGkqhV/eV+uA5nMsfYiHJkWSMjOz//k9t9tVnF1tuzpQO52D2Xg9OGF/M Fw5QpiF/3NG7RnPrd1hpBzsSuAV5QIPrMO9NeKc4iqMwOfWo82Ia4xNB+2EPBiVJ7D hopCos4t4+sgWdTgnYZQqrJBrAYZCrobEdDHdbC3GgiFpDppcRSqhM08aJSD+z3zSg wUowr8UtnFt2WwowMS44As5GuqhztGmy2SlIskkgVCQ43I0W4NIx4MGPdNXscTVLI/ yt2H6yJjEKreg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fRD8G3zRSz4wCW; Thu, 05 Mar 2026 13:32:14 +1100 (AEDT) Date: Thu, 5 Mar 2026 13:20:22 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] tcp: Avoid comparison of expressions with different signedness in tcp_timer_handler() Message-ID: References: <20260304163203.2440767-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="q8RnIalUknkJ3isf" Content-Disposition: inline In-Reply-To: <20260304163203.2440767-1-sbrivio@redhat.com> Message-ID-Hash: CYXVKIQCAVJU3AYYBOZHAVQQTOOZ3NU7 X-Message-ID-Hash: CYXVKIQCAVJU3AYYBOZHAVQQTOOZ3NU7 X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Yumei Huang X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --q8RnIalUknkJ3isf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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): >=20 > tcp.c: In function 'tcp_timer_handler': > util.h:40:39: warning: comparison of integer expressions of different sig= nedness: '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 =3D 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 =3D MIN(TCP_MAX_RETRIES, max); > | ^~~ >=20 > for some reason, that's not reported by gcc with glibc. >=20 > Make the temporary 'max' variable unsigned, as we know it can't be > negative anyway. >=20 > While at it, add the customary blank line between variable > declarations and code. >=20 > Fixes: 3dde0e07804e ("tcp: Update data retransmission timeout") > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > tcp.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > 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 e= poll_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 =3D c->tcp.syn_retries + c->tcp.syn_linear_timeouts; > max =3D MIN(TCP_MAX_RETRIES, max); > if (conn->retries >=3D max) { > --=20 > 2.43.0 >=20 --=20 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 --q8RnIalUknkJ3isf Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmmo6GUACgkQzQJF27ox 2GetaQ/9Fa+e4iXK/Gke6PmQN/RPP6Ykd8ANoZkyWFZl2J/sax2FFSoPxpiSMh7i 5fskwpp4404Tz8NYSpbNqhLotzbMixYp6hZBfIPzYc/v2L5MzA2RQvTvuuntnN0c WfsiDnTMOhYTHdDL+CbkfwQLCygqJQgbat3HVjg+uWd8oO4c5c4xoWWaEJPISHJ/ snk6fPGZRmb+bxEXvqSosghSTFoo3ahGojNXFzU/5F9va1R987HQf+fEXpptgww5 eO6b/KtF1C/I4v7nKxCAv762/Q+Uu8Z2xGDFJd0RgOUjuai+bkmzzHS56XiVOtbX W4ypRrn3brxJz7WGWbsgvBg4oy8D5MeFJJR56DVpxIUwJVfczwh80c7+hb6LHm3m 4ftfL1anGEnYuta/C6BdzZL9q1e20jjg8iAVOFh1xyG6JJuAGP7AI9oQ38Rq+SMK 6uz5uv7+3pjmtnCpofZ5ed/5TZAquUvfa/wocdceSvEkqKkkPiRBiQq8lE7OIo7C JcxSJz/UW4Tr9t0edNpHZKdXIvyNiRK/bR8vlh7t80RQr/An0kL1zZiSW5JLgjod NdgvGzt+n6AXoA6nnOD/dDmA+kUCqokJJH15DfHh0Uw4L9UON/KpGdSrsnFA7j6D AZOvXtud0MjL77zlT7yPhZ8D6+laxJvlq3mEBQn9TX6VyzHZbYo= =2e02 -----END PGP SIGNATURE----- --q8RnIalUknkJ3isf--