Message ID | 20211021085132.12672-1-elibr@nvidia.com (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Thomas Monjalon |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5B2A8A0547; Thu, 21 Oct 2021 10:52:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D183E411B1; Thu, 21 Oct 2021 10:52:25 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2076.outbound.protection.outlook.com [40.107.237.76]) by mails.dpdk.org (Postfix) with ESMTP id 2523D40142; Thu, 21 Oct 2021 10:52:24 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M+obvaABe5pvPLuw5rceviP9cZaS2fCOsxnqEgHdXzPERRWzADrntx4zcwA2OhAUcN54FrwvMfM+4WOncLq+FO9Z+DeMkz+ZQVPKuEo8SMLKxS/zH+igBa9ZO2K7FGtdQxKnVf0y28gC39D2OwML780c5u8HWPKCoGyL462NvN/MVRnMkUkwWaw5CV3KLS0jLb+2FfHIJaMOhvwSvf08l0KcTD68Xm/oyP5C1KzMv4ezE/ADHE/SvO/Q7Kn9xJuRghKCoqvqPh0hQIEFnoQBrOKKwdNlLzN9LfZPIZbsVMijBG6e0ARkpAMh2TEhkgGn5YU5OPzkkBpE6RoC/SdlcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i2GZBemq/0JQwc/oyHVfrwjelncQWaQmXCsjW4/qZEo=; b=LMf88sWdhY4z/w1a0fKSEy+VwhoxUmLQJAAV9gtQSKRHrIIAgFD13h9pHw5tgqByfrIY2Dce5ew1Js9fzSzvwCyGzIY+n2FJ8UjvKzeo4uFoM82EjQbgEER/BUNP2yaiZLq2Y8n7LEmZ/Qsr67+nQ/TfDbptwXacE6ZtNyW/AGAE0J0DoOgr7kTAN5KEsxNI1jyN3sfVNJELIW+twnSClshxnMk8XAGyLf6NDcEdKyGnbCk5APDs2ioeqdy9Hsb82ZqDMlRNq5JU2ac4SPifv3tSOEBVAimgF0FiKrIJGvT1aJPBuiUjQ2chmIod0ZDh3Q4SBuHb/1kLqK0o/OMBgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i2GZBemq/0JQwc/oyHVfrwjelncQWaQmXCsjW4/qZEo=; b=jRRNoDXfi8KNnct4fQ90pnXlS7AiqeK5vKkwUr3QeWYAKHV3mRRiV6ZW3ZPHYEudWt+KZ/VbyT/gaEzgoAmiiULBv2r9le+cl52y+kJm+nj91NRF2/Eo97p+fhqOmPcImp2zKxfCJ/6QvAdP+rRzNT9hiiYHppbTRtc1eInlWaf+Ii75upkrfF88n3JxCoEpYWR1+eYIK5WRmvgy/Vw3N1qFwmqtuVQkfA2A467g2j1rgXzjT63Pkdlswl5uGXohHveMSiHK6TJ6NYlho0gOYOaHvvE7fHV02Ygu9KuJt8H0aWoFm5UnRRKGe+EKLyxoCU2Eq9yvbrBxUKkXiLWvbA== Received: from MW4PR04CA0087.namprd04.prod.outlook.com (2603:10b6:303:6b::32) by DM6PR12MB4895.namprd12.prod.outlook.com (2603:10b6:5:1bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.15; Thu, 21 Oct 2021 08:52:21 +0000 Received: from CO1NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6b:cafe::44) by MW4PR04CA0087.outlook.office365.com (2603:10b6:303:6b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Thu, 21 Oct 2021 08:52:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT033.mail.protection.outlook.com (10.13.174.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4628.16 via Frontend Transport; Thu, 21 Oct 2021 08:52:20 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 21 Oct 2021 08:52:17 +0000 From: Eli Britstein <elibr@nvidia.com> To: <dev@dpdk.org> CC: Matan Azrad <matan@nvidia.com>, Asaf Penso <asafp@nvidia.com>, "Slava Ovsiienko" <viacheslavo@nvidia.com>, Thomas Monjalon <thomas@monjalon.net>, <bruce.richardson@intel.com>, <konstantin.ananyev@intel.com>, <olivier.matz@6wind.com>, Eli Britstein <elibr@nvidia.com>, <stable@dpdk.org> Date: Thu, 21 Oct 2021 11:51:30 +0300 Message-ID: <20211021085132.12672-1-elibr@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210713064910.12793-1-elibr@nvidia.com> References: <20210713064910.12793-1-elibr@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e902f2f-5cfc-4fa5-dbcb-08d9947017d3 X-MS-TrafficTypeDiagnostic: DM6PR12MB4895: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: <DM6PR12MB48952219D640FE622DB352F4D8BF9@DM6PR12MB4895.namprd12.prod.outlook.com> X-MS-Oob-TLC-OOBClassifiers: OLM:61; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6WP+GE3S2HLLPUtEyeHP1Nlh5BqtZmNkVJfK68MFAVqpjYTT2QJMgVgE3/RjOD+Jj9Lc4FOhlA/f5bUg2L1fDXwYhZpkRt4jEThoOXCHfNJ3Q/4AbAwt2cCBGTqnyME5WVB8BTHuifj9cgLWGJbRfrRe6Nw47pNGcCQcQaMwOqrCNuqDEDfTL+krDeInD+msbQSZ3cFy7X/IIHYFdzl+M1lh36QK6b77edvTMmEQETcD4FqDNMwwzlGUW0HGk0rvbj9S1oc2H7fau6+YAbnPfTMeWdEJ74gW3hm99RdZkItWtBpMWKCE+L33ZAuHvIf9/ni+ZrmuWdVRfY4eRI8OLv+9vc43KQHCgqmqQK7n0lV0hLzC8EUsUiZVwZ5hibtbvbjLCe24ZTSy0Op3Cy1l0Cz88Dx/YQjQq1G9jcI/h1zFjjX4oFqnZFeEO2M5rFZIPBxcza12d//lipEuDc+IE3CebQk+ZV2fKh1XVMmCd8v36Pc1BGxM41m7cEbF3eeurrBujexG5esvPim3HzbfvKiGSZN6bJse61IFzrTMWzrfGZyiF74+tpZUlriSsuMhrJ8jUi7Tj/QIRXECzg/ud6PuD647Wwun002FsZiqqkO3kfWcP7xw40W+yEaHSf8eXrE9+aXlqHS53xvTUvT+TVLmThHS2cjg+nfcR46vWt5cVwjgjqk9YFVqQ9h79lsSZCHqUsDafwcVbKERis5GLQ== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(36860700001)(2616005)(26005)(2906002)(7636003)(356005)(5660300002)(1076003)(16526019)(82310400003)(6666004)(186003)(83380400001)(8676002)(336012)(47076005)(316002)(508600001)(54906003)(36906005)(6916009)(8936002)(4326008)(36756003)(426003)(70206006)(6286002)(7696005)(55016002)(86362001)(70586007); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2021 08:52:20.5644 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e902f2f-5cfc-4fa5-dbcb-08d9947017d3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4895 Subject: [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 <dev.dpdk.org> List-Unsubscribe: <https://mails.dpdk.org/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://mails.dpdk.org/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://mails.dpdk.org/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Series |
[V2,1/3] net: avoid cast-align warning in VLAN insert function
|
|
Checks
Context | Check | Description |
---|---|---|
ci/checkpatch | success | coding style OK |
Commit Message
Eli Britstein
Oct. 21, 2021, 8:51 a.m. UTC
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 <elibr@nvidia.com> Acked-by: Olivier Matz <olivier.matz@6wind.com> --- lib/net/rte_ether.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, 21 Oct 2021 11:51:30 +0300 Eli Britstein <elibr@nvidia.com> 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 <elibr@nvidia.com> > Acked-by: Olivier Matz <olivier.matz@6wind.com> 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.
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 <elibr@nvidia.com> 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 <elibr@nvidia.com> >> Acked-by: Olivier Matz <olivier.matz@6wind.com> > 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?
On Thu, 21 Oct 2021 19:16:19 +0300 Eli Britstein <elibr@nvidia.com> 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 <elibr@nvidia.com> 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 <elibr@nvidia.com> > >> Acked-by: Olivier Matz <olivier.matz@6wind.com> > > 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.
diff --git a/lib/net/rte_ether.h b/lib/net/rte_ether.h index b83e0d3fce..9febb60300 100644 --- a/lib/net/rte_ether.h +++ b/lib/net/rte_ether.h @@ -367,7 +367,7 @@ static inline int rte_vlan_insert(struct rte_mbuf **m) return -EINVAL; oh = rte_pktmbuf_mtod(*m, struct rte_ether_hdr *); - nh = (struct rte_ether_hdr *) + nh = (struct rte_ether_hdr *)(void *) rte_pktmbuf_prepend(*m, sizeof(struct rte_vlan_hdr)); if (nh == NULL) return -ENOSPC;