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 920C5A0C53 for ; Thu, 21 Oct 2021 18:22:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8552E410FF; Thu, 21 Oct 2021 18:22:35 +0200 (CEST) Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by mails.dpdk.org (Postfix) with ESMTP id BFA4540E6E for ; Thu, 21 Oct 2021 18:22:33 +0200 (CEST) Received: by mail-pg1-f180.google.com with SMTP id m21so749810pgu.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=PI47/uVxZvNpjl+tlcigt5Urefiv50UPqxKMqfY0vZJBzAbwLtoXUsj2vzVlYHQqqV KWTfyZfb2gEXbYc6SU/lXy4Vdegi2gF5i1u0pP1GcId4NJ2bNcgdQyWomB/lCwEeRyWy uwj1PAgfi9pL4un0AY3mVWpkw8mYPQRWi/q7/T96GMclaDPbwftGhQ6rslTLvkAjGo8Z 9kZJ/Dl60+j53lxeq+gLsPQqIvhT3SwWpyFv3BncE5R6DnMz7hZvIBn+1mFdF1UrkTyp bIRDfNPVIXXtDImCyRDwf3Algqsxlv9ZtCddcEAX4DI51Qz0sH83G8GvbRPRLKTxusVi fWCQ== X-Gm-Message-State: AOAM5331sSi2NeNgfA9naxIAmGEWPjkiHGz3YBe6EUg2AHcE6iWF/2Xw 5OJzI/Rnkw0R6P4WvhNIIs+Cag== 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-stable] [dpdk-dev] [PATCH V2 1/3] net: avoid cast-align warning in VLAN insert function X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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.