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 02233A0C43; Tue, 19 Oct 2021 11:47:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D4FEB40683; Tue, 19 Oct 2021 11:47:05 +0200 (CEST) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mails.dpdk.org (Postfix) with ESMTP id 7B61F4003E for ; Tue, 19 Oct 2021 11:47:05 +0200 (CEST) Received: by mail-wm1-f52.google.com with SMTP id 63-20020a1c0042000000b0030d60716239so2030252wma.4 for ; Tue, 19 Oct 2021 02:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=RIMwK/kfKeYsnpw8zfEDv7XcjojX3ltp+22XFlSicb0=; b=QgxlV3NJJmEuYZY08fSkxMIE20KAYQc6UmdDxYO+5vvQpTFuudcdhofhM785jB9cRl 9EwHRjMihh6fizMB5Igzc8Mbkp80aDaF8EsMWpCFI4G7tObVGK08cMjcenMD0KTGce2+ J8v0zdq2hWdRnXhUN1OveSFnoCfoKqi6FSrLhbeNd9D5I7rQNPAl894QpHqr7M2MnvV/ 4QURRcY1Ofetjtaa79xEe+kemicWDRV8wJjVEbqVRGm+ZgBwRGTdpaRf2F+RAh0mXSUA byzgdiQt1EBdcxBNiWXbZkiLwaTz9X8GZ9lv1A/M9OTtrH8INKYgVJCF54X0s5JlDZnF oEhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=RIMwK/kfKeYsnpw8zfEDv7XcjojX3ltp+22XFlSicb0=; b=c2oc8Mvjf+54nAe26jyDQzKC8ZHeEVwr0AJZa13c4Dn5dZCKOprSJd98A9DF1ZK3U+ iYDsiWka8Ukt2F0WZZRFXafkuxsflbsf/LwVUIf6EFVYTG8hUCXOsz8fMvIpiLJiqCJ9 mRITUIe3s589ADz+axU3HcXjow6Xmh6xqTok2jllp7REKAkHGu6lFUhZYlfIy16UwAD4 3/5FgEnRYzhR7UscV/LL0ekHnm91Qi/96RQXaCJ4nnzNfgU483xHsdNNkdhtIFsKKf0Z 6r4SumfzfM9ri+BjZWl+9AnPuZdkAMt1VlhqWuKHsAba+6R5K0bVTny1TJMJf1iFkP68 COZw== X-Gm-Message-State: AOAM530D5Yiqvg/CZq5ku20LicHKTJZlPzriwl9C8vX+4ck9x7Db0/YJ 6840aTSotMFhbvTimC1O9WrzAg== X-Google-Smtp-Source: ABdhPJz7IQ0/5te2PBjmrNYO08hWeBmmTvl+O3ltgVuoBOSY8GZLNZQX/PP113mjvL7AbU1FPpeWJQ== X-Received: by 2002:a05:600c:2904:: with SMTP id i4mr4792343wmd.9.1634636825183; Tue, 19 Oct 2021 02:47:05 -0700 (PDT) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id l2sm5858174wrs.90.2021.10.19.02.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 02:47:04 -0700 (PDT) Date: Tue, 19 Oct 2021 11:47:03 +0200 From: Olivier Matz To: Eli Britstein Cc: dev@dpdk.org, Ilya Maximets , Gaetan Rivet , Majd Dibbiny , Asaf Penso , Thomas Monjalon , Harry Van Haaren , stable@dpdk.org, Andrew Rybchenko Message-ID: References: <20210713064910.12793-1-elibr@nvidia.com> <20210713064910.12793-3-elibr@nvidia.com> <045f7d4b-c9dc-0a1e-25c8-359f14dfcc66@nvidia.com> <5a8ec545-bc65-ab18-2043-0c27fb027530@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Subject: Re: [dpdk-dev] [PATCH 2/3] mbuf: avoid cast-align warning in pktmbuf mtod offset macro 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 Sender: "dev" Hi Eli, On Tue, Oct 19, 2021 at 09:41:56AM +0300, Eli Britstein wrote: > Hi Olivier, > > On 8/1/2021 11:06 AM, Eli Britstein wrote: > > > > On 7/30/2021 2:10 PM, Olivier Matz wrote: > > > External email: Use caution opening links or attachments > > > > > > > > > Hi Eli, > > > > > > On Thu, Jul 29, 2021 at 10:13:45AM +0300, Eli Britstein wrote: > > > > On 7/28/2021 6:28 PM, Olivier Matz wrote: > > > > > External email: Use caution opening links or attachments > > > > > > > > > > > > > > > On Tue, Jul 13, 2021 at 09:49:09AM +0300, Eli Britstein wrote: > > > > > > In rte_pktmbuf_mtod_offset macro, there is a casting > > > > > > from char * to type > > > > > > 't', which may cause cast-align warning when using gcc flags > > > > > > '-Werror -Wcast-align': > > > > > > > > > > > > .../include/rte_mbuf_core.h:723:3: error: cast increases > > > > > > required alignment > > > > > >       of target type [-Werror=cast-align] > > > > > >     723 |  ((t)((char *)(m)->buf_addr + (m)->data_off + (o))) > > > > > >         |   ^ > > > > > > > > > > > > As the code assumes correct alignment, add first a (void > > > > > > *) casting, to > > > > > > avoid the warning. > > > > > > > > > > > > Fixes: af75078fece3 ("first public release") > > > > > > Cc: stable@dpdk.org > > > > > > > > > > > > Signed-off-by: Eli Britstein > > > > > My initial thinking was that it's the problem of the application: if > > > > > -Werror=cast-align is used, it is up to the application to cast the > > > > > return value of rte_pktmbuf_mtod_offset() to (void *) before > > > > > casting it > > > > > to the network type. > > > > > > > > > > But, if I understand correctly, the problem is not about the > > > > > application > > > > > code itself, but about inlined code in the header files of dpdk > > > > > (i.e. compiling an empty C file that just includes the dpdk > > > > > headers with > > > > > -Werror=cast-align). Is it correct? If yes I think it should be > > > > > highlighted in the commit log. > > > > I think yes, though in this specific patch it is not even an inline > > > > function, but a macro. > > > > > > > > However, I don't have a synthetic application example to show those > > > > warnings, thus didn't put such in the commit msg. > > > For this patch, I think it would be useful to have a way to reproduce > > > the issue first, so we can check whether it is the proper place to fix > > > the problem. > > --- a/examples/l2fwd/Makefile > > +++ b/examples/l2fwd/Makefile > > @@ -22,6 +22,7 @@ static: build/$(APP)-static > >         ln -sf $(APP)-static build/$(APP) > > > >  PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) > > +CFLAGS += -Wcast-align=strict > >  CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) > > > > gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0 > > Copyright (C) 2019 Free Software Foundation, Inc. > > This is free software; see the source for copying conditions. There is NO > > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR > > PURPOSE. > > > > make -C examples/l2fwd clean static > > To reproduce locally with DPDK only, no need to change any file. Only run: > > CFLAGS="-Wcast-align=strict" make V=1 -C examples/l2fwd clean static > > How would you like to proceed? Sorry, I missed your previous message. I reproduced the issue, with a slightly modified command: # no error, my gcc is 8.3.0-6 (debian) CFLAGS="-Wcast-align=strict" make V=1 -C examples/l2fwd clean static # bad option name with clang CC=clang CFLAGS="-Wcast-align=strict" make V=1 -C examples/l2fwd clean static ... warning: unknown warning option '-Wcast-align=strict'; did you mean '-Wcast-align'? [-Wunknown-warning-option] # problem reproduced with clang CC=clang CFLAGS="-Wcast-align" make V=1 -C examples/l2fwd clean static main.c:170:8: warning: cast from 'char *' to 'struct rte_ether_hdr *' increases required alignment from 1 to 2 [-Wcast-align] eth = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/rte_mbuf_core.h:830:32: note: expanded from macro 'rte_pktmbuf_mtod' #define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/rte_mbuf_core.h:816:3: note: expanded from macro 'rte_pktmbuf_mtod_offset' ((t)((char *)(m)->buf_addr + (m)->data_off + (o))) I confirm the patch fixes the issue. Acked-by: Olivier Matz Thanks