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 BDD70A0A0C; Wed, 28 Jul 2021 17:28:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 49F6D40E64; Wed, 28 Jul 2021 17:28:50 +0200 (CEST) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by mails.dpdk.org (Postfix) with ESMTP id 68FE540142 for ; Wed, 28 Jul 2021 17:28:49 +0200 (CEST) Received: by mail-wr1-f53.google.com with SMTP id b9so3037159wrx.12 for ; Wed, 28 Jul 2021 08:28:49 -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:in-reply-to; bh=GQxY29TYkeHqZ0/upypK9fK1/TTFUQDDF/UZgtyNt3Q=; b=JlaF1Z9RQ9lezaq0/O4Xu/KY48+bzFkFFhnNqItw0JI4RiqTD3O73FVmU3PzgOfE4r +5SZYtuHxdfulmsC9Koh35PyMusXskQYHAJ0EruvCmVS957oTfBduSaQLDIXgEVfeFIC AKe75zKdMapK0KAfeoLpLNBoL413J8c6z0bZ1Yk9HGA37P6i0AZpQr6ot+9Rb6gHQ49m ennF4jt9/Z+9gfP5RGIiqpFYX89clFcZsF+1vOqKGhq7eb0fI7Mgenhi7qQnMuAWnOcr BvtPoFplLhLmHHtOWVo+HdQA0R5rEp5x980VTszC2PQfuYNioeQDXpQiAf2hAh+hUQLN xB3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GQxY29TYkeHqZ0/upypK9fK1/TTFUQDDF/UZgtyNt3Q=; b=AhGjrabrn6/o7p3quHAn0uW19IWFetbJfEjDiLbEQolelUC6T6nVFNNxQoFXoAgLSy Ri0P94nPV0iDbM38mGilFWKJY5/qPf/HNdaTiWD7NA8K3IM2epTqPvUBo46ystvg71Bi WWInMwwjyYqXYermgd1WXBvkbIgTPtOVDh3gECwEB75aCVa3yJJe3S5bYGSJ6zFTmFti uht91Ow/xz/nZCacEu0jl0bm2M4Z/rKDSWXeBGoDGA9pbFJzbXPBttRNREkHp9iYoVGr wX8NvA/3ddkFuBWGRWGFTZSpyVZlDLUKPTZS+ubCituFqKOtgyd3AflD7Z0QObkzb8cD Y0mw== X-Gm-Message-State: AOAM5325ZgvV/3aU79b5W3fysGLySleOHASPqzL2JKP7Od8rDuQRPnaG U8476R2j4oEaGHgVSRHMtD5XaQ== X-Google-Smtp-Source: ABdhPJzEPVHynVAFy4BBBHn1Gb7mEXhkBnGL+lst2R3eRzFwOyzCXn2wg0qKuLkQgUit3uULTcZPjQ== X-Received: by 2002:adf:c803:: with SMTP id d3mr31427753wrh.345.1627486129131; Wed, 28 Jul 2021 08:28:49 -0700 (PDT) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id r2sm138369wrq.15.2021.07.28.08.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 08:28:48 -0700 (PDT) Date: Wed, 28 Jul 2021 17:28:47 +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 Message-ID: References: <20210713064910.12793-1-elibr@nvidia.com> <20210713064910.12793-3-elibr@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210713064910.12793-3-elibr@nvidia.com> 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" 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. Out of curiosity, how did you find the errors? I mean, is it possible that some casts are missing some other headers, or is this patchset exhaustive? Thanks, Olivier > --- > lib/mbuf/rte_mbuf_core.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h > index bb38d7f581..dabdeee604 100644 > --- a/lib/mbuf/rte_mbuf_core.h > +++ b/lib/mbuf/rte_mbuf_core.h > @@ -720,7 +720,7 @@ struct rte_mbuf_ext_shared_info { > * The type to cast the result into. > */ > #define rte_pktmbuf_mtod_offset(m, t, o) \ > - ((t)((char *)(m)->buf_addr + (m)->data_off + (o))) > + ((t)(void *)((char *)(m)->buf_addr + (m)->data_off + (o))) > > /** > * A macro that points to the start of the data in the mbuf. > -- > 2.28.0.2311.g225365fb51 >