From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 29B805A0279 for ; Thu, 30 Nov 2023 10:06:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701335213; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3pw3vgKv1iKtyqY+S2P5lYpIxDtocb0in7Mwo5nMiW0=; b=ZYo9tl3OoGLMhx/mrR/BrsWfBjPbhht4Zhl/PwZpmCYI9+tC8H/Fcjcb+tKHwA4JdwPCFk j7wBmTy0IRq+cVUTILKbBSEKHD0ryQYZ205MUGqDQi4jK7HQ3wWkAmWZmBYj3jAJKTio1p hRToAoYEJZqPjdLH3BkKETbUjf6Iy4M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-A-eVm9U7MquELz5eCf7f-g-1; Thu, 30 Nov 2023 04:06:49 -0500 X-MC-Unique: A-eVm9U7MquELz5eCf7f-g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 693CC811E8D; Thu, 30 Nov 2023 09:06:49 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 67A1D10EA1; Thu, 30 Nov 2023 09:06:48 +0000 (UTC) Date: Thu, 30 Nov 2023 10:06:46 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 1/4] treewide: Use 'z' length modifier for size_t/ssize_t conversions Message-ID: <20231130100646.11566f82@elisabeth> In-Reply-To: References: <20231129134610.3796809-1-sbrivio@redhat.com> <20231129134610.3796809-2-sbrivio@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: JSOP7VGAXZE4GX6RKAOZ3VZ4R47CB6NN X-Message-ID-Hash: JSOP7VGAXZE4GX6RKAOZ3VZ4R47CB6NN X-MailFrom: sbrivio@redhat.com 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: On Thu, 30 Nov 2023 11:15:47 +1100 David Gibson wrote: > On Wed, Nov 29, 2023 at 02:46:07PM +0100, Stefano Brivio wrote: > > Types size_t and ssize_t are not necessarily long, it depends on the > > architecture. > > Most LGTM, but a couple of nits: > > [snip] > > @@ -106,7 +106,7 @@ void *packet_get_do(const struct pool *p, size_t idx, size_t offset, > > > > 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, " > > The change here is certainly correct. But the remaining %lu is > dubious. The value given is the sum of a uint32_t and two size_t, so > it could depend on platform what exactly that will be promoted to. I > think we should probably either cast the result explicitly to (size_t) > and use %zu, or cast to (uint32_t) and use "%" PRIu32. > > [snip] > > diff --git a/tcp_splice.c b/tcp_splice.c > > index a5c1332..8d08bb4 100644 > > --- a/tcp_splice.c > > +++ b/tcp_splice.c > > @@ -321,7 +321,7 @@ static int tcp_splice_connect_finish(const struct ctx *c, > > > > 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 = 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 == EINTR) > > goto retry; > > @@ -580,7 +580,7 @@ eintr: > > written = 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 %zu)", > > written, to_write); > > 'to_write' is actually an ssize_t which would suggest %zi. However > looking at the code, I think to_write probably *should* be a size_t > instead. Oops, I didn't notice. Well, I know we're passing it to splice(), but we're also using it like this: if (!never_read && written < to_write) { to_write -= written; goto retry; } so I'd rather keep it as ssize_t for the moment (and re-spin this series with a %zi here), just in case we happen to do something silly with it and ssize_t is saving us. -- Stefano