From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 571F345A2A; Wed, 25 Sep 2024 17:24:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 439F84025D; Wed, 25 Sep 2024 17:24:17 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 5E01F400EF for ; Wed, 25 Sep 2024 17:24:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727277855; 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=8jeL3CdpdS4VflYBU6YO+dyYrevFGvhyibVtDFUkTy0=; b=IThhsz2Xo3fQcSgTEghfHxOxsjv4mELeP/uMf5PGrUgXk8+T6kcE+bUZdDZcKyNEq9MLAv AMdFHKnFHB0zis9GwwlkD0I/p2du9kfcNHM/SxFeUWTRBoS4iT+Racw/W7WQBN44XF2nC7 bTs/mXORECrQo8RPxaXWKTbdlDvoGQ4= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-225-l3FjDvumM-iGaorN9aXXEA-1; Wed, 25 Sep 2024 11:24:14 -0400 X-MC-Unique: l3FjDvumM-iGaorN9aXXEA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6cb25c3c532so342976d6.0 for ; Wed, 25 Sep 2024 08:24:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727277853; x=1727882653; h=in-reply-to:references:user-agent:from:cc:subject:to:message-id :date:content-transfer-encoding:mime-version:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=1CZnA0ChEst1VgUyVwq25NS1b1DTVsoDXDF46FWswx0=; b=HIhBEeNrhjQsC8Bm+IQik9Sv0ILHK1go7DniZhjUbr+kvu70Sp2+E/b8QwptezGXHa 3kN+iXk+Pocte+uQDmzLJehiGrUQYlwWys0nGOBW4JR9mlPMfTpAild+cvWyRCQNAkx9 FcFf4UpBZ4Y66AtFD17BHmMHMDgCC7TewcgQgCNxkKtJEnysIKAF8cKNU9s1o7aVF99E tPReI75JrLX6iNCvBKM0JS6kWTqtQ4g6BFeLh38O6XAN35+JscNeKQ00eLDKtHGwJ6ih +HBfw4FgwJl8dxx+77v/ESfHTTlmqvKlTV1SBIZkNfjnEKrUQ2LkVa0yqF8dsggXpYNo /EAg== X-Gm-Message-State: AOJu0Yyhqo53spHkAc+NheH1gckRZGRrvvWY3ez6K3ClRtgTda6X203K bqjda5DoPbYlF8wBOcaocfQWtJmPoLqV6OcaK0i3zxXNB/09Uk34E4bURBKsYzenp/1cvuy7Mv0 p9exqGkCNlfLP9h60DwFDHxq+HrH8Bk+AeXV+RVPf2T4eSNBo6T0= X-Received: by 2002:a05:6214:3d08:b0:6c5:508d:7f81 with SMTP id 6a1803df08f44-6cb1dd6860emr57084996d6.26.1727277853552; Wed, 25 Sep 2024 08:24:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7TlHjc/DtQK4tztPFYEGwCJ/6QSeJZzM/7MC3XFkPbuRQw8iqJkQmNryQkZRJk+QnHmgzLQ== X-Received: by 2002:a05:6214:3d08:b0:6c5:508d:7f81 with SMTP id 6a1803df08f44-6cb1dd6860emr57084726d6.26.1727277853179; Wed, 25 Sep 2024 08:24:13 -0700 (PDT) Received: from localhost ([173.242.185.50]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6a3dsm17024446d6.29.2024.09.25.08.24.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Sep 2024 08:24:12 -0700 (PDT) Mime-Version: 1.0 Date: Wed, 25 Sep 2024 11:24:12 -0400 Message-Id: To: "Stephen Hemminger" , =?utf-8?q?Morten_Br=C3=B8rup?= Subject: Re: [PATCH dpdk] mbuf: fix strict aliasing error in allocator Cc: From: "Robin Jarry" User-Agent: aerc/0.18.2-62-g3b42f3130eb7-dirty References: <20240925140021.46320-2-rjarry@redhat.com> <98CBD80474FA8B44BF855DF32C47DC35E9F72F@smartserver.smartshare.dk> <20240925082307.7162e556@fedora> In-Reply-To: <20240925082307.7162e556@fedora> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Stephen Hemminger, Sep 25, 2024 at 11:23: > On Wed, 25 Sep 2024 17:21:12 +0200 > Morten Br=C3=B8rup wrote: > > > From: Morten Br=C3=B8rup > > To: "Robin Jarry" , > > Subject: RE: [PATCH dpdk] mbuf: fix strict aliasing error in allocator > > Date: Wed, 25 Sep 2024 17:21:12 +0200 > >=20 > > > From: Robin Jarry [mailto:rjarry@redhat.com] > > > Sent: Wednesday, 25 September 2024 10.00 > > >=20 > > > When building an application with -fstrict-aliasing -Wstrict- > > > aliasing=3D2, > > > we get errors triggered by rte_mbuf_raw_alloc() which is called inlin= e > > > from rte_pktmbuf_alloc(). > > >=20 > > > ../dpdk/lib/mbuf/rte_mbuf.h: In function =E2=80=98rte_mbuf_raw_alloc= =E2=80=99: > > > ../dpdk/lib/mbuf/rte_mbuf.h:600:42: error: dereferencing type-punned > > > pointer might break strict-aliasing rules [-Werror=3Dstrict-aliasing= ] > > > 600 | if (rte_mempool_get(mp, (void **)&m) < 0) > > > | ^~ > > >=20 > > > Avoid incorrect casting by changing the type of the returned variable= . > > >=20 > > > Signed-off-by: Robin Jarry > > > --- > > > lib/mbuf/rte_mbuf.h | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > >=20 > > > diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h > > > index babe16c72ccb..bab1fb94d41d 100644 > > > --- a/lib/mbuf/rte_mbuf.h > > > +++ b/lib/mbuf/rte_mbuf.h > > > @@ -595,9 +595,9 @@ __rte_mbuf_raw_sanity_check(__rte_unused const > > > struct rte_mbuf *m) > > > */ > > > static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool > > > *mp) > > > { > > > -=09struct rte_mbuf *m; > > > +=09void *m; > > >=20 > > > -=09if (rte_mempool_get(mp, (void **)&m) < 0) > > > +=09if (rte_mempool_get(mp, &m) < 0) > > > =09=09return NULL; > > > =09__rte_mbuf_raw_sanity_check(m); > > > =09return m; =20 > >=20 > > Suggest: > > =09__rte_mbuf_raw_sanity_check((struct rte_mbuf *)m); > > =09return (struct rte_mbuf *)m; > > Another way to avoid the warning would be to use a union? I can use an inline union, it will be less code.