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 070EDA0C52; Thu, 21 Oct 2021 18:22:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9631340E6E; Thu, 21 Oct 2021 18:22:34 +0200 (CEST) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id B9D6E40683 for ; Thu, 21 Oct 2021 18:22:33 +0200 (CEST) Received: by mail-pf1-f172.google.com with SMTP id x66so1066147pfx.13 for ; Thu, 21 Oct 2021 09:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P1qoMQq0V+TcQhx1C8YwJY5HTsw/8D2mBQNuCQB8feM=; b=xU713PPtObyr4XQFfX3T3K2nQvJA6SgpOlneCip9n95Ei4eqMrFs39B8osZ1FL7HJG Eyiy9d/4FFxelD3CnqXbbu5rHM/vu1BJCE32JLexX8wVwVK3Q4JkMlJydMWyCWZJwi0Q DXT1/yj384WcGr/pfGt0hdw2iuwmnXt549fN3iALpSIJRbDhGLjEiAbmR7w8lw2nLQyP e46+a34rOmcOa6ab1ClmhvgqfYkH6dD2dRdpktjWbVKtKUUJCiQa+P+BUWpKLTCIWJAM c96ilwXpBcasJaJKxHfPZBxSdM5Yfec88mY+wU0dcESLEhw4i/WFC5wn7pw+NUAettHy etag== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=P1qoMQq0V+TcQhx1C8YwJY5HTsw/8D2mBQNuCQB8feM=; b=pvtdfuEPLB5jA1TAz0KTERk/38wB2q9esV9KOVu3Eae5tVnvLYTwsAatx9eH0g9Rh0 gE0gWPLsxHi1lIRBLUyODuPyLRER6/sjNzT7kqicGtQxP7yKPTHV266QRfbN62L0bUYl 3gh4QLXMi05/8QrrUeweVsXIBjXCtakECxChtuXZi7+h/lEdAMOcLPdI78FRbUAD+Aox h4p2r6z2VKMamrVfs36AWSjIqeqgl8ZguhJlNPKrm5gVYyprU5ErVnd3aoB30W4XXUYQ a1WqRywBag3r8TkYLCaGDyOymGr1150KuN8EYbX2inLjtpq5+rUhRMlKHUbiLzlMdyf8 yKlQ== X-Gm-Message-State: AOAM532aK0IqtTObix2XhKEK3ngnepBMTOibOMhwzABu+n/i+mtU2uhC JiMiMWUgMznVVszBPz7aQPO3xw== X-Google-Smtp-Source: ABdhPJyu3rAKM4+kEtEi1qJX0nKsAiQzBjQGBgf3+lv7PHaaaysJvNvk7y2LkWD/SllZOz9CicdU5A== X-Received: by 2002:a63:9207:: with SMTP id o7mr5171389pgd.236.1634833352761; Thu, 21 Oct 2021 09:22:32 -0700 (PDT) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id y13sm5950702pgc.46.2021.10.21.09.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:22:32 -0700 (PDT) Date: Thu, 21 Oct 2021 09:22:29 -0700 From: Stephen Hemminger To: Eli Britstein Cc: , Matan Azrad , Asaf Penso , Slava Ovsiienko , Thomas Monjalon , , , , Message-ID: <20211021092229.6fcf55b0@hermes.local> In-Reply-To: <1ce86c5c-6255-398b-de8a-8c79c6c747cd@nvidia.com> References: <20210713064910.12793-1-elibr@nvidia.com> <20211021085132.12672-1-elibr@nvidia.com> <20211021084848.21e24030@hermes.local> <1ce86c5c-6255-398b-de8a-8c79c6c747cd@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH V2 1/3] net: avoid cast-align warning in VLAN insert function 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 Thu, 21 Oct 2021 19:16:19 +0300 Eli Britstein wrote: > On 10/21/2021 6:48 PM, Stephen Hemminger wrote: > > External email: Use caution opening links or attachments > > > > > > On Thu, 21 Oct 2021 11:51:30 +0300 > > Eli Britstein wrote: > > > >> In rte_vlan_insert there is a casting of rte_pktmbuf_prepend returned > >> value to (struct rte_ether_hdr *), which causes cast-align warning when > >> using strict cast align flag with supporting gcc: > >> gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 > >> CFLAGS="-Wcast-align=strict" make V=1 -C examples/l2fwd clean static > >> > >> In file included from main.c:35: > >> /dpdk/build/include/rte_ether.h:370:7: warning: cast increases required > >> alignment of target type [-Wcast-align] > >> 370 | nh = (struct rte_ether_hdr *) > >> | ^ > >> > >> As the code assumes correct alignment, add first a (void *) casting, to > >> avoid the warning. > >> > >> Fixes: c974021a5949 ("ether: add soft vlan encap/decap") > >> Cc: stable@dpdk.org > >> > >> Signed-off-by: Eli Britstein > >> Acked-by: Olivier Matz > > After cast to void * the second cast is not necessary. > > > > nh = (void *)rte_pktmbuf_prepend(...) > > > > Ideally rte_pktmbuf_prepend() should return void * but that is > > an API change. > > Removing the second cast, it is silently done anyway, as 'nh' is of type > 'struct rte_ether_hdr *'. > > Going with this approach (I can also do it for patch 3/3), we can change > rte_pktmbuf_prepend to return (void *), and let the applications using > it do the silent cast. > > What do you think? Changing return type is an API change so it would need the whole multistep process. I overstated a little, it turns out the cast is necessary when header is included by C++ code. C++ is pickier and doesn't allow void * to be converted to other type by assignment. Probably best to stick with what you originally proposed. Gcc does have a bunch of alignment attribute types that could also fix this but that gets even messier.