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.129.124]) by passt.top (Postfix) with ESMTP id 0929A5A0279 for ; Thu, 30 Nov 2023 10:06:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701335204; 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=MopsW3iaXnuN/xmaugzaK3RcTvsb0S9xTxNBUp+MA0g=; b=P6PcarkTcAUhoWig3wXLUO5RdpskdBBNI0LXI9FAKbs09Gi2J4AFm/t8mzR+wFg/bv0i1I UO1kA1sbRM7IOD9Cck5Rzx73wd9m1EkCysNZWKlahPBEEg1UKZtX9T6Z542GPjNfd7tb+n gkRwzvNKEhAWQlsb28Ujuj0s4Q4yINg= 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-195-5KfAYOcuOn2Q2SLgE3rHzA-1; Thu, 30 Nov 2023 04:06:42 -0500 X-MC-Unique: 5KfAYOcuOn2Q2SLgE3rHzA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 52DA8811E7D; Thu, 30 Nov 2023 09:06:42 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32D942026D4C; Thu, 30 Nov 2023 09:06:40 +0000 (UTC) Date: Thu, 30 Nov 2023 10:06:20 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/4] packet: Offset plus length is not always uint32_t, but it's always size_t Message-ID: <20231130100620.7668c2df@elisabeth> In-Reply-To: References: <20231129134610.3796809-1-sbrivio@redhat.com> <20231129134610.3796809-3-sbrivio@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: P2SFQQRCNVYHVHKB43BT6XTH7AA6UPUG X-Message-ID-Hash: P2SFQQRCNVYHVHKB43BT6XTH7AA6UPUG 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:18:48 +1100 David Gibson wrote: > 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. > > > > 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. > > > > > Signed-off-by: Stefano Brivio > > --- > > packet.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > 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, > > > > 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); > > } >