From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 8B6BD5A004E for ; Mon, 24 Jun 2024 03:21:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1719192098; bh=0+jiMheNvawd/zo8qs/6mh6Y0DU7QWiS6fWdv8k0lzU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GrwPY1utEUh/7M+hu3IupjLaEF7BFClDNIHp3Md5KOhSwP6y2L5KJXJhYEas0/bxc ZcDyJO+/JtX5aBCgjr8P0P//IX7Dmv6qukmdJkzYc74tdtoz2Kgz0FT+HhSGbjMqVh 5XH2NsHWOo3RL20NZQ7OZsENku9NGKh4xYiK4bwRvbXF9umUt0HB9aaiPwSkOyztNh nmG1GseALMZXpAG5EWvqhlPXKVQ85V6WQYcUyr1WkowkYeyi2QdiXhjmrJ8WOZGeCX Aw0zJn61ByNvsJ7RZMDtyXfS1ni2Gi1JCiLLkMIAxqvLhPzXkdR+CoAwvP4o567v0o ccEZep+UnnEPw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4W6qtV0CPzz4wc1; Mon, 24 Jun 2024 11:21:38 +1000 (AEST) Date: Mon, 24 Jun 2024 11:21:29 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 2/2] udp: Reduce scope of rport in udp_invert_portmap() Message-ID: References: <20240621155323.1313483-1-sbrivio@redhat.com> <20240621155323.1313483-3-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0S9gqVCghb9a3rj2" Content-Disposition: inline In-Reply-To: <20240621155323.1313483-3-sbrivio@redhat.com> Message-ID-Hash: NB7BLIZMBM2WQ5PZE67UI2TPSW2MYLU7 X-Message-ID-Hash: NB7BLIZMBM2WQ5PZE67UI2TPSW2MYLU7 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, Laurent Jacquot 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: --0S9gqVCghb9a3rj2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 21, 2024 at 05:53:23PM +0200, Stefano Brivio wrote: > cppcheck 2.14 warns that the scope of the rport variable could be > reduced: do that, as reverted commit c80fa6a6bb44 ("udp: Make rport > calculation more local") did, but keep the temporary variable of > in_port_t type, otherwise the sum gets promoted to int. >=20 > Reported-by: David Gibson > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > udp.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/udp.c b/udp.c > index 8181900..a854323 100644 > --- a/udp.c > +++ b/udp.c > @@ -279,10 +279,12 @@ static void udp_invert_portmap(struct udp_fwd_ports= *fwd) > "Forward and reverse delta arrays must have same size"); > for (i =3D 0; i < ARRAY_SIZE(fwd->f.delta); i++) { > in_port_t delta =3D fwd->f.delta[i]; > - in_port_t rport =3D i + delta; > =20 > - if (delta) > + if (delta) { > + in_port_t rport =3D i + delta; > + > fwd->rdelta[rport] =3D NUM_PORTS - delta; > + } > } > } > =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 --0S9gqVCghb9a3rj2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmZ4yhgACgkQzQJF27ox 2GezMg/8DSrIC0RvBJx2/z8ceVnG3WojUQVT9MGUSCds1zLZBdNG//qh43UaQ+Tc feTzykzDARmYUWpx181YQzWQiRd5hNWoHSJEamu3DACDMKX5a/uZpmR+aPaHcy8x XmA79OX3E9lVA986md3JTllrXtgb1YBcspbHXCD7OffZHXfbSDZbfkkVIgiZq4Xu fxFesrDL+ESBjuPD9ZUcoomrvYxk0dLn//tfz+tBY92LsVgsBX/b7DugYsA+uvPF tUgDg85vimfEESUnNnA94mmx2mIe6/lE46tp0g1gMhlv04/iG0MLevmg6vFJHgn2 13Kxf8erNkWo4QsAfj9t1TgIn4XqvJphO6fmRjdmjP2GCLgGxW7siYTz44DdybTO 69VELmS/jO+ai47JhHz6iGZjVLL8NXYM4ZRcBUyZzy170qPSngXNLXzq80smBgB5 CKi6f55fZbBaq1T3BLsujBfCNCyK1L95VIxVTTm8fgHiftjnVP4hI+yxpBx+oS4m +FN0pJNRJovuj4tjqtwUFSLMDZ4x7kKYCDH8HMKL1PYXcYyuxIEWeP6MwcRsITSa H2SYZvAim8Hw/Wyduoq9k4PKUi/hdotsazYMQKe4NJDLxmFHB0fdPFckLwLhPIZ6 XTzhcPWNwM8OjekUv36wVSVJ4CKn/jtECb1OHjc+7e+z1F33n7I= =HLXa -----END PGP SIGNATURE----- --0S9gqVCghb9a3rj2--