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 4683945A2A; Wed, 25 Sep 2024 17:23:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D7C9F4025D; Wed, 25 Sep 2024 17:23:11 +0200 (CEST) Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by mails.dpdk.org (Postfix) with ESMTP id 10036400EF for ; Wed, 25 Sep 2024 17:23:10 +0200 (CEST) Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-4585721f6edso46534021cf.2 for ; Wed, 25 Sep 2024 08:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727277789; x=1727882589; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=+pl/Qe3tMSNwWaRV+99kZYq06f4rVOtKtG3BsujFzJE=; b=z83lNTdwPCrHp33ri0sC+09Aj7jsRGG32LvM32rUlDAZ37mnWJsOkUxv850g1lGHhI JwqQjq7QI/cIM5RD3Ke6dxIKBA/VRsLVR1aVMiGtpgCymNfiQlPwAXUt0XqAhJWvsc1E rNNotwU4mtwfA1pqJys/xyp7H29OHqFHWwFCiJMB7Wy4pE2if9xrUof+Vp0mfB8j1fNh IE8pdZm9UKVzUE25QSQhzeUrJJMbrEWTfDclsatmUXn22BbACHO6NDBd3pEoFaT7vWDI xL20ZnSGDHSTxqwUAllY6Ey+WQglFZ6PtOi0pVITvjv/NiIXfSS4kuA43dABAPDERN7Q IpzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727277789; x=1727882589; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+pl/Qe3tMSNwWaRV+99kZYq06f4rVOtKtG3BsujFzJE=; b=w/iG+DPYUN90LxSE1XsI2X7WKSrBCeIll+bHwaqglkG6q3miy53LK0iJD6aO5IXmdR usuNZKwP00cw9LKL8xrCUSpF1lJ3eGruaV4SkT/RUfws/z8dnPsiWC8qa8OKIr0o62Qs 9L2ulhWxOQz5wgR0DYvvP70jOScHjN+Dt3/AGLAm8h0n9FyNNHJbllrDVTw9rIoBnSCi cNYIBEZ1qXIzk2rdu92S0cOxLUtPIJ2R95MZfJIZK66nSsKKzm6CijYqyDTzjPDix1gF nnTKd3Z8tiwFuY7JPqcRJMIxQZ+w/DCUw8u/Uhvu7jAD3AztH+3CE3QWLvtJ0wEBnZnF f7BA== X-Forwarded-Encrypted: i=1; AJvYcCU4H1Ip2cR1yPDMs/3lZIdwk30IhXKgy9NgAnn4uosRnKJHclwGw889wDhEH5Zy1Z5p4wY=@dpdk.org X-Gm-Message-State: AOJu0YyhWLOS7BFBQR+Ke3ifE30aBbwBZ2MafkGcDzzNbijRtWiHAMK9 rXXf15ROZcTNpIiP1r1zU4KthXYPoPq8IqPa70SKHwkKjCp+KrxdTyOX3+A7972WoM/tmS9G5C1 aV+M= X-Google-Smtp-Source: AGHT+IEn35KVmZJ4Pttzg+ibPrXL8lZpBlIs0NQ5sNKL0Msl5pQPHqP8COfclxqz3VESdGwuNUTczA== X-Received: by 2002:a05:622a:c1:b0:458:28c9:5de2 with SMTP id d75a77b69052e-45b5decd74amr53974681cf.5.1727277789261; Wed, 25 Sep 2024 08:23:09 -0700 (PDT) Received: from fedora ([173.242.185.50]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45b52686c3asm16996041cf.80.2024.09.25.08.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 08:23:08 -0700 (PDT) Date: Wed, 25 Sep 2024 08:23:07 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: "Robin Jarry" , Subject: Re: [PATCH dpdk] mbuf: fix strict aliasing error in allocator Message-ID: <20240925082307.7162e556@fedora> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F72F@smartserver.smartshare.dk> References: <20240925140021.46320-2-rjarry@redhat.com> <98CBD80474FA8B44BF855DF32C47DC35E9F72F@smartserver.smartshare.dk> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 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 inline > > 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) > > { > > - struct rte_mbuf *m; > > + void *m; > >=20 > > - if (rte_mempool_get(mp, (void **)&m) < 0) > > + if (rte_mempool_get(mp, &m) < 0) > > return NULL; > > __rte_mbuf_raw_sanity_check(m); > > return m; =20 >=20 > Suggest: > __rte_mbuf_raw_sanity_check((struct rte_mbuf *)m); > return (struct rte_mbuf *)m; Another way to avoid the warning would be to use a union?