From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id A89F15A027B for ; Thu, 30 Nov 2023 01:55:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1701305703; bh=b+3nW0cvDxCK6gLxdbSiN5MLUu4s3Rx16OECb90dLLM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ltGsulifPl89L1w5NhshvskdvRmfSMql1TOCli2QPZ4umajbd76YBGEklWuM5nRon k9VeKagnULg0l/Mq+F+cSIqwkL7gZbhGWnA4v7RU+Kd+vUwvBDOCVhyK3dQCWxVT82 f6XHzM6dRGqbjI5JTaQ9BsE8BUoMMO2aDFgwZBIs= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Sgd5M3QSZz4xW9; Thu, 30 Nov 2023 11:55:03 +1100 (AEDT) Date: Thu, 30 Nov 2023 11:18:48 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 2/4] packet: Offset plus length is not always uint32_t, but it's always size_t Message-ID: References: <20231129134610.3796809-1-sbrivio@redhat.com> <20231129134610.3796809-3-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vMUTeGMS7gUSFTZq" Content-Disposition: inline In-Reply-To: <20231129134610.3796809-3-sbrivio@redhat.com> Message-ID-Hash: U3JABMVBQER3LZ7SCOG5Q5N5XP5ZNUUE X-Message-ID-Hash: U3JABMVBQER3LZ7SCOG5Q5N5XP5ZNUUE 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, lemmi@nerd2nerd.org 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: --vMUTeGMS7gUSFTZq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 29, 2023 at 02:46:08PM +0100, Stefano Brivio wrote: > According to gcc, PRIu32 matches the type of the argument we're > printing here on both 64 and 32-bits architectures. According to > Clang, though, that's not the case, as the result of the sum is an > unsigned long on 64-bit. >=20 > Use the z modifier, given that we're summing uint32_t to size_t, and > the result is at most promoted to size_t. Heh, sorry, obviously hadn't read this patch when I commented on this spot in the first one. The problem here is that the final promoted type depends on whether size_t is wider than uint32_t or not, which can vary with architecture. That said, I doubt we're likely to support anything with a size_t strictly *less* than 32-bits, so %zu is probably safe. >=20 > Signed-off-by: Stefano Brivio > --- > packet.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/packet.c b/packet.c > index 12ac76b..ccfc846 100644 > --- a/packet.c > +++ b/packet.c > @@ -106,7 +106,7 @@ void *packet_get_do(const struct pool *p, size_t idx,= size_t offset, > =20 > if (p->pkt[idx].offset + len + offset > p->buf_size) { > if (func) { > - trace("packet offset plus length %lu from size %zu, " > + trace("packet offset plus length %zu from size %zu, " > "%s:%i", p->pkt[idx].offset + len + offset, > p->buf_size, func, line); > } --=20 David Gibson | 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 --vMUTeGMS7gUSFTZq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmVn1OcACgkQzQJF27ox 2Gchzg/+PDdvP7EAtTF4mA4sXMQjxH4XncyMvZR2ySug69PGPi9+LM9WovyUvXg0 LjEacEOWbKfUpFucbZB/yDYhGreBw5zfVwJFFSc+8jgN1c+0y64Lyn/WKkU82j3a XXjg2KP7zxqWnos8X0BZZcnnsRrTaSHasysDW10kitVY2obmsQl3Em0OjSnJRNIg /4sD6HVWZ4BYXelj8WPCcm6mwkn3WMIbgx+saTDQJnj3945i3huBxuRR3vsde/dc BKW5cQuig5W528xQzonWV7DFwjLcwFGFICGnGHuS0ERvo3WL9fsrCvMV7ZWjtP8k ygIHOQrBqf8PXzbc6w9LF2qNXy7FmH2FqE5A8THSbkRbJNCCjqCFnNyrQZZbPnrv PZ/0BXu/jzr4lf1VoHSuKrHdBfrOZEZOuJIN75AAKxAribnaHFtz3hThd5jXb9a9 OXAtVo5pLFVqDI91wlOqRdxen/N9OOduoy78v44+FLEpJs6Xo7fiZT3XgnQD+ZSL LSWUREg8VtT8BWNDyW7JCRA3p2l4TLRLnysBmanQVa4Gf7pDERew8scG8mK9QkK9 FN9btfaDOekwC/0Xx5SgjvcJBK+wzOS3LMN5o1+OT5luLPvw/Ahf0Qr/iAXGn2wh XFKc5Pad66EEf4fLHfPyeMxulXOHjdWVCA6aJ8dEsfqj7gu55uE= =pvEH -----END PGP SIGNATURE----- --vMUTeGMS7gUSFTZq--