From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id D6D395A027F for ; Fri, 1 Dec 2023 01:02:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1701388964; bh=5q9nTkizUXYuhByapvTWlRVfNahyE1PvxByXASr+A1s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=O//rYJvtw6ETz5PBWSczVq8JHO5FWXIeDJWh9JDnHVRhbYz0vpxrArC9rdrqpOCtD U8+BRjhlsPHcVqydSZ75Z3p4cb0TuYqmwQPmS0OuAUthk506sF+D1hclyI8BY3HNS3 20H8oRIIinUXnkFe2DPebqbwTV663PBUYSY6Tjqg= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ShCtX1C4tz4wx5; Fri, 1 Dec 2023 11:02:44 +1100 (AEDT) Date: Fri, 1 Dec 2023 11:01:59 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 1/3] treewide: Use 'z' length modifier for size_t/ssize_t conversions Message-ID: References: <20231130100726.4151850-1-sbrivio@redhat.com> <20231130100726.4151850-2-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VXizIJYnw9YWRE11" Content-Disposition: inline In-Reply-To: <20231130100726.4151850-2-sbrivio@redhat.com> Message-ID-Hash: ZGFW33U3W65ZAYGSQ7HDBKM7HRFWEKAE X-Message-ID-Hash: ZGFW33U3W65ZAYGSQ7HDBKM7HRFWEKAE 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: --VXizIJYnw9YWRE11 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 30, 2023 at 11:07:24AM +0100, Stefano Brivio wrote: > Types size_t and ssize_t are not necessarily long, it depends on the > architecture. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > netlink.c | 2 +- > packet.c | 14 +++++++------- > pcap.c | 4 ++-- > tap.c | 12 ++++++------ > tcp.c | 3 ++- > tcp_splice.c | 8 ++++---- > 6 files changed, 22 insertions(+), 21 deletions(-) >=20 > diff --git a/netlink.c b/netlink.c > index 6cc04a0..379d46e 100644 > --- a/netlink.c > +++ b/netlink.c > @@ -130,7 +130,7 @@ static uint32_t nl_send(int s, void *req, uint16_t ty= pe, > if (n < 0) > die("netlink: Failed to send(): %s", strerror(errno)); > else if (n < len) > - die("netlink: Short send (%lu of %lu bytes)", n, len); > + die("netlink: Short send (%zd of %zd bytes)", n, len); > =20 > return nh->nlmsg_seq; > } > diff --git a/packet.c b/packet.c > index 9589824..12ac76b 100644 > --- a/packet.c > +++ b/packet.c > @@ -36,7 +36,7 @@ void packet_add_do(struct pool *p, size_t len, const ch= ar *start, > size_t idx =3D p->count; > =20 > if (idx >=3D p->size) { > - trace("add packet index %lu to pool with size %lu, %s:%i", > + trace("add packet index %zu to pool with size %zu, %s:%i", > idx, p->size, func, line); > return; > } > @@ -48,14 +48,14 @@ void packet_add_do(struct pool *p, size_t len, const = char *start, > } > =20 > if (start + len > p->buf + p->buf_size) { > - trace("add packet start %p, length: %lu, buffer end %p, %s:%i", > + trace("add packet start %p, length: %zu, buffer end %p, %s:%i", > (void *)start, len, (void *)(p->buf + p->buf_size), > func, line); > return; > } > =20 > if (len > UINT16_MAX) { > - trace("add packet length %lu, %s:%i", len, func, line); > + trace("add packet length %zu, %s:%i", len, func, line); > return; > } > =20 > @@ -90,7 +90,7 @@ void *packet_get_do(const struct pool *p, size_t idx, s= ize_t offset, > { > if (idx >=3D p->size || idx >=3D p->count) { > if (func) { > - trace("packet %lu from pool size: %lu, count: %lu, " > + trace("packet %zu from pool size: %zu, count: %zu, " > "%s:%i", idx, p->size, p->count, func, line); > } > return NULL; > @@ -98,7 +98,7 @@ void *packet_get_do(const struct pool *p, size_t idx, s= ize_t offset, > =20 > if (len > UINT16_MAX || len + offset > UINT32_MAX) { > if (func) { > - trace("packet data length %lu, offset %lu, %s:%i", > + trace("packet data length %zu, offset %zu, %s:%i", > len, offset, func, line); > } > return NULL; > @@ -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 %lu, " > + trace("packet offset plus length %lu from size %zu, " > "%s:%i", p->pkt[idx].offset + len + offset, > p->buf_size, func, line); > } > @@ -115,7 +115,7 @@ void *packet_get_do(const struct pool *p, size_t idx,= size_t offset, > =20 > if (len + offset > p->pkt[idx].len) { > if (func) { > - trace("data length %lu, offset %lu from length %u, " > + trace("data length %zu, offset %zu from length %u, " > "%s:%i", len, offset, p->pkt[idx].len, > func, line); > } > diff --git a/pcap.c b/pcap.c > index 524612a..501d52d 100644 > --- a/pcap.c > +++ b/pcap.c > @@ -101,7 +101,7 @@ void pcap(const char *pkt, size_t len) > =20 > gettimeofday(&tv, NULL); > if (pcap_frame(pkt, len, &tv) !=3D 0) > - debug("Cannot log packet, length %lu", len); > + debug("Cannot log packet, length %zu", len); > } > =20 > /** > @@ -123,7 +123,7 @@ void pcap_multiple(const struct iovec *iov, unsigned = int n, size_t offset) > for (i =3D 0; i < n; i++) { > if (pcap_frame((char *)iov[i].iov_base + offset, > iov[i].iov_len - offset, &tv) !=3D 0) { > - debug("Cannot log packet, length %lu", > + debug("Cannot log packet, length %zu", > iov->iov_len - offset); > return; > } > diff --git a/tap.c b/tap.c > index 4f11000..2ceda8d 100644 > --- a/tap.c > +++ b/tap.c > @@ -191,7 +191,7 @@ void tap_udp4_send(const struct ctx *c, struct in_add= r src, in_port_t sport, > memcpy(data, in, len); > =20 > if (tap_send(c, buf, len + (data - buf)) < 0) > - debug("tap: failed to send %lu bytes (IPv4)", len); > + debug("tap: failed to send %zu bytes (IPv4)", len); > } > =20 > /** > @@ -214,7 +214,7 @@ void tap_icmp4_send(const struct ctx *c, struct in_ad= dr src, struct in_addr dst, > csum_icmp4(icmp4h, icmp4h + 1, len - sizeof(*icmp4h)); > =20 > if (tap_send(c, buf, len + (data - buf)) < 0) > - debug("tap: failed to send %lu bytes (IPv4)", len); > + debug("tap: failed to send %zu bytes (IPv4)", len); > } > =20 > /** > @@ -278,7 +278,7 @@ void tap_udp6_send(const struct ctx *c, > memcpy(data, in, len); > =20 > if (tap_send(c, buf, len + (data - buf)) < 1) > - debug("tap: failed to send %lu bytes (IPv6)", len); > + debug("tap: failed to send %zu bytes (IPv6)", len); > } > =20 > /** > @@ -302,7 +302,7 @@ void tap_icmp6_send(const struct ctx *c, > csum_icmp6(icmp6h, src, dst, icmp6h + 1, len - sizeof(*icmp6h)); > =20 > if (tap_send(c, buf, len + (data - buf)) < 1) > - debug("tap: failed to send %lu bytes (IPv6)", len); > + debug("tap: failed to send %zu bytes (IPv6)", len); > } > =20 > /** > @@ -364,7 +364,7 @@ static void tap_send_remainder(const struct ctx *c, c= onst struct iovec *iov, > ssize_t sent =3D send(c->fd_tap, base + offset, len - offset, > MSG_NOSIGNAL); > if (sent < 0) { > - err("tap: partial frame send (missing %lu bytes): %s", > + err("tap: partial frame send (missing %zu bytes): %s", > len - offset, strerror(errno)); > return; > } > @@ -433,7 +433,7 @@ size_t tap_send_frames(const struct ctx *c, const str= uct iovec *iov, size_t n) > m =3D tap_send_frames_pasta(c, iov, n); > =20 > if (m < n) > - debug("tap: failed to send %lu frames of %lu", n - m, n); > + debug("tap: failed to send %zu frames of %zu", n - m, n); > =20 > pcap_multiple(iov, m, c->mode =3D=3D MODE_PASST ? sizeof(uint32_t) : 0); > =20 > diff --git a/tcp.c b/tcp.c > index 40e3dec..44468ca 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -2570,7 +2570,8 @@ int tcp_tap_handler(struct ctx *c, uint8_t pif, int= af, > return 1; > } > =20 > - trace("TCP: packet length %lu from tap for index %lu", len, CONN_IDX(co= nn)); > + trace("TCP: packet length %zu from tap for index %lu", > + len, CONN_IDX(conn)); > =20 > if (th->rst) { > conn_event(c, conn, CLOSED); > diff --git a/tcp_splice.c b/tcp_splice.c > index a5c1332..0a23584 100644 > --- a/tcp_splice.c > +++ b/tcp_splice.c > @@ -321,7 +321,7 @@ static int tcp_splice_connect_finish(const struct ctx= *c, > =20 > if (fcntl(conn->pipe[side][0], F_SETPIPE_SZ, > c->tcp.pipe_size)) { > - trace("TCP (spliced): cannot set %d->%d pipe size to %lu", > + trace("TCP (spliced): cannot set %d->%d pipe size to %zu", > side, !side, c->tcp.pipe_size); > } > } > @@ -554,7 +554,7 @@ retry: > readlen =3D splice(conn->s[fromside], NULL, > conn->pipe[fromside][1], NULL, c->tcp.pipe_size, > SPLICE_F_MOVE | SPLICE_F_NONBLOCK); > - trace("TCP (spliced): %li from read-side call", readlen); > + trace("TCP (spliced): %zi from read-side call", readlen); > if (readlen < 0) { > if (errno =3D=3D EINTR) > goto retry; > @@ -580,7 +580,7 @@ eintr: > written =3D splice(conn->pipe[fromside][0], NULL, > conn->s[!fromside], NULL, to_write, > SPLICE_F_MOVE | more | SPLICE_F_NONBLOCK); > - trace("TCP (spliced): %li from write-side call (passed %lu)", > + trace("TCP (spliced): %zi from write-side call (passed %zi)", > written, to_write); > =20 > /* Most common case: skip updating counters. */ > @@ -718,7 +718,7 @@ static void tcp_splice_pipe_refill(const struct ctx *= c) > =20 > if (fcntl(splice_pipe_pool[i][0], F_SETPIPE_SZ, > c->tcp.pipe_size)) { > - trace("TCP (spliced): cannot set pool pipe size to %lu", > + trace("TCP (spliced): cannot set pool pipe size to %zu", > c->tcp.pipe_size); > } > } --=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 --VXizIJYnw9YWRE11 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmVpInYACgkQzQJF27ox 2GdWCg//TX9leWNDN/LKjhRm32Q5wGlik7jJsZm3l4/ElFT1WE1v9JDMaDApo+aa fS7mxjfRugeZAdjEQVQLXdqQdWqzD6/42eUos3WMKXSrDeJNuyBpHSwz6ZQSJAhv ZYQJzo3cmjLy4A6e63l5mfUT5guAE21UMLPW8Pbl78B7vdbBQOI0+nG/tLw9yRVR vVrXMhpZ+aNsUB0MQSx7RHAT1j+V2WVcWAPeG+Qg7akBF/RgzMOnxCj0eFtM0s2S K6TzGQE3Cbnby04ze7G5n6iQiy+7Xq6BkQ14CIFKEXh6vaa4DYxoS6BCSSeWcVUw 8mzwtKYEGoB7aYsRDzLKOyosg9AcVDwhlfKFv0RznP0dlXAUPTIAxpj8kDhF3uHb huk0V3qeU/U/y3lwYabMQcg/ozugjpIWV7Iaw9ulVBms6QIOCAZMZah2c+E6G7CL 4m6qEhzGllVCGEI0t0Er+RoqJ+ScAvWgLNGikUCvwDScK9capYLO/3NyxH6PFBFs /FDxZFTF8bKkBDKwHmPzxSyeoJRu+yVG5xbVZDL0VKM6FZCPbY8CvOIb6ANshaC3 WYZEMCg2/ZvRdwkQf9M0erN7iNc6TEaH8U8NR4M8LRFTz/d5rPI/9GqFxfZGtdLz OPK0f/EDrK4zb+K7EjR7ln9KgSlk2jpINs9ST/akt/jkoOFUyPw= =7dNB -----END PGP SIGNATURE----- --VXizIJYnw9YWRE11--