From patchwork Fri Feb 9 18:14:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10209785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8AE4860236 for ; Fri, 9 Feb 2018 18:14:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7476B29759 for ; Fri, 9 Feb 2018 18:14:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68B4429956; Fri, 9 Feb 2018 18:14:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 375F829759 for ; Fri, 9 Feb 2018 18:14:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751090AbeBISOW (ORCPT ); Fri, 9 Feb 2018 13:14:22 -0500 Received: from mail-eopbgr00057.outbound.protection.outlook.com ([40.107.0.57]:56786 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751052AbeBISOV (ORCPT ); Fri, 9 Feb 2018 13:14:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=vT/JIF3YZEWHanKnQ9xuUDDhflhJKU6J0WFIIBo6sW4=; b=ak5H8Ca9PXADBFZJrZNVg+0MK/oNvMGvizHrBIeq+do5j8xm88erVonzJhfwXhv1DVZRTB5bQPiHz5102MyxkBasPzWYMCcj2gw0gwbxBYsl3W0K3fMlBwqr9RW9WvQbHa3RUcY4x7IyArUVsPlnWJKqfswvzHmvl0PikOeJBhQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jgg@mellanox.com; Received: from mlx.ziepe.ca (70.74.179.152) by HE1PR0501MB2857.eurprd05.prod.outlook.com (2603:10a6:3:c1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Fri, 9 Feb 2018 18:14:17 +0000 Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1ekDBa-0003yo-8q; Fri, 09 Feb 2018 11:14:10 -0700 Date: Fri, 9 Feb 2018 11:14:10 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org, Bart Van Assche , Thomas Monjalon Subject: [RFC PATCH rdma-core] Check that public headers support -Wpedantic Message-ID: <20180209181410.GA15016@ziepe.ca> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [70.74.179.152] X-ClientProxiedBy: AM5PR0701CA0002.eurprd07.prod.outlook.com (2603:10a6:203:51::12) To HE1PR0501MB2857.eurprd05.prod.outlook.com (2603:10a6:3:c1::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 90de8d56-8f8f-4758-0967-08d56fe8eed2 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:HE1PR0501MB2857; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2857; 3:04PoZllFcMms7NDFfyIec8COOL3mDVYVBFoGSwKBgk3qZ9X76obticSAzp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B/mXuSEdeoFDkUBEFJFAr4omufchrRsRyQ4HYPKklysEkdUlZ2Et3TYkhqW9pOt27n5CuZsD77lfD4WoZZP2lBqFo0KVVwXHgLw1w/e1/2Y+gZnntsVLdzdGLrmv9v6T/5LCDw5BHo5gK3Uco3dxyRl2U9OwvPSo12g/omp9jyldgg2cCxE8J/5DM0t2RoMMPkjjK2TC6SHT9L9ybE+36E7mTRkLkfvJHdXaM2LMEfdi51zGNM+sSLHVeeiy2Cu9SJx7hPbdLK3JX3VQYuq5uLkxfFK2Nj+jworNReqKXkhAicaADm2k; 4:cLez6rxTGHcEg0Tap4jqK5WT/4huEQ8UcGnKO7HoUFgFDHiPew/h/N925L9Llox81K+z7bbnAR0im+nTxHHJa71EUzTLOpSeBsjJBaQIx5FGhRlnS0r+KWzLdJ/SlIDxPCrU7vLUynpS0YqLRr8clLplJ3dMQKzgbIcTkD7a9JK09xd5UeIGqOnG+BQzQ7ebZpcAppAbr/xSF2teX8WqJZyStutRfNr/ypljiUGvOwCFeRH/TYV1s+m57z04zbIHwK/v/x5nDpkXmxRTlHuPrMItYhPgATFhBxGTcgLBOW+7p4KrkKiR5i2im/wuhct/ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(5213294742642); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(3002001)(3231101)(2400082)(944501161)(93006095)(93001095)(10201501046)(6055026)(6041288)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:HE1PR0501MB2857; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2857; X-Forefront-PRVS: 057859F9C5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39380400002)(396003)(39860400002)(366004)(376002)(189003)(199004)(122856001)(86362001)(97736004)(57986006)(81166006)(81156014)(105586002)(106356001)(6636002)(47776003)(9786002)(46656002)(66066001)(83796002)(69596002)(9746002)(7736002)(110136005)(58126008)(16586007)(478600001)(52116002)(59450400001)(33896004)(386003)(316002)(33656002)(8936002)(53936002)(2906002)(9686003)(1076002)(68736007)(6116002)(83506002)(3846002)(23726003)(5660300001)(26005)(50466002)(8676002)(186003)(305945005)(36756003)(18370500001)(24400500001)(42262002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2857; H:mlx.ziepe.ca; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0501MB2857; 23:c/Z5b+SFPCzVOQdJRG2QXCSh+OTH3buHnlAZenu?= =?us-ascii?Q?NkquZRO3OmNQH/WhWkSGYh2ng+h48pt6IBV86NugBfNEV1im3Bj2Ji6/25YQ?= =?us-ascii?Q?TpzUHPV0+A/6gMby1iWv0MbzZgYtJJo3rNK7Jw5cK+awT1A228D1mAhl4xTp?= =?us-ascii?Q?BVgYEGRYmDmTQJjbP8q7wTOUjm0QwpO1Tp7NFMgkoNTjVMDiFy4KmHlwS3fi?= =?us-ascii?Q?eDUMpzNHwExo/xQKQUeNHUNkG4ogkyIl19vsy9mtgcuYTQoqqkNGkvRJ2yUl?= =?us-ascii?Q?75LH7ElprzXSG3PG6ElKZZaGT/VyTIdB5LKOPBmYSuPDDYABIsD9mhnSb4P/?= =?us-ascii?Q?bC++c7Mt2D39WTmmsM7JbLpOd3UMnt2TQtNoGiQ1VqrsG2B1JRJ8vIAzE6Xb?= =?us-ascii?Q?AvaQUrjOgFuh35fOmtWEcIeshYXOOWclAcmzzK5/0CGz6zP9mmFnsCZX/DGt?= =?us-ascii?Q?l65b0TzayKOhT2lWUcCmvcoQ3bCgeo2VRpCj0KSaNmmrlmfB9WkusyQTAro1?= =?us-ascii?Q?A1JlFLbAFsoPMz73AkmHRvwl+xFdw6eYHv0Vgdnr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O5l8dB3FOtKGD2f6DSz6X90XLNJ7xejkYxdfV5GMufuurpbeChq+yvEHGW40g9kCdxJjckFs+8y/5mV02Fxu2ZG5kLnOymZOnuk9XvHY2HMf74v+vDA2q3b17yCQliayhQFsimKi+wn4CQlJXFy33wNsA5i18c7DGozVPoEI8tuUex9lp/zmQjnbSEIg7dDpmc4G08tNS+sz5Zjg6zbU8aPdBd1aQCdb5LL21OeAO88oOSvsSiISjN80OYv51Siwo=; 5:05/WNPDPlrB3MCytjmX0OlhzqvTesjEbj+H+6GlbObLnghqtI4OWLtg9HNbsKPAoO+UQQsvZ2WUvT39IfmFNXh/0nsE/fwL3FHcuZHfXS4xSTRHs2prDOLC6KjFOcxOohk9Vpm7+jbM/e63mxA6Nr65Fu2CSJsUmUvbWD9umgSU=; 24:Q+vUAIhpuf3RBB+Hm/rhNYbQJsAnngTe/2miV1XiWUvSwLzjgfKc2hH/HrmpshKjhyV4lonI5jYOAFJYkfi3yNCsWCIbh0Dm0HcDMxGRqa0=; 7:wJF0TqdTjGLA0AA8QqiBwYPvvGQy80f4WjtTGkDViLKmCMtDDwzpKqsnpSbPrvkUNvQmS5FVPJuTOJ8SIle3Wij9Lxbba9kHVgfniTWx7scClESIoSIhQJLmaVxgDLy/coxyU1kVr/K+/CToNqRNqimuOwewK5aTbB/n+zrXdvhCKRmEor+ZIjh2Y2W6A3K2zyMTIWsW9eIoDl1Jl/edBd7+HK9fIJEMfmVfHIYH59YoA1ZFsT6FyoxdR7Zur1oR SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2018 18:14:17.0600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90de8d56-8f8f-4758-0967-08d56fe8eed2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2857 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We do require a C11 compiler, but can support -Wpedantic compilation, at least on some headers. This actually catches a few mistakes, like the 1<<31. Signed-off-by: Jason Gunthorpe --- buildlib/check-build | 6 +++--- libibverbs/verbs.h | 26 +++++++++++++++++++++----- providers/mlx4/mlx4dv.h | 6 +++--- providers/mlx5/mlx5dv.h | 12 +++--------- 4 files changed, 30 insertions(+), 20 deletions(-) Lets consider this a bit experimental for now. This changes the public headers to be mostly pedantically correct as far as C11 (but not C99). There are still uses of zero length arrays in some rdma-cm headers, but the verbs and dv headers are clean. The main issue is what Bart recently pointed out, that the use of an enum constant beyond the range of 'int' is a (popular) compiler extension, so they have to change to #define check-build is updated so the CI will continuously validate this. I also haven't carefully checked the _verbs_get_ctx_op at this point, won't bother if we don't want to do this. That change is needed because the result statement expression thing is also an extension. I noticed this as some projects like DPDK are compiling with -Wpedantic and have to make special provision for verbs.h Jason diff --git a/buildlib/check-build b/buildlib/check-build index 766db7ae46259f..b8b678a743c1bc 100755 --- a/buildlib/check-build +++ b/buildlib/check-build @@ -213,10 +213,10 @@ def get_headers(incdir): includes.add(os.path.join(root,I)); return includes; -def compile_test_headers(tmpd,incdir,includes): +def compile_test_headers(tmpd,incdir,includes,xargs="-std=gnu11"): with open(os.path.join(tmpd,"build.ninja"),"wt") as F: print >> F,"rule comp"; - print >> F," command = %s -Werror -c -I %s $in -o $out"%(args.CC,incdir); + print >> F," command = %s -Werror -c -I %s $in -o $out %s"%(args.CC,incdir,xargs); print >> F," description=Header check for $in"; count = 0; for I in sorted(includes): @@ -280,7 +280,7 @@ def test_installed_headers(args): with open(I,"w") as F: print >> F,'#error "Private internal header"'; - compile_test_headers(tmpd,incdir,includes); + compile_test_headers(tmpd,incdir,includes,xargs="-std=c11 -D_GNU_SOURCE -Wpedantic -Wno-zero-length-array"); # ------------------------------------------------------------------------- diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 5325f8fe412276..e83acbc7dc8568 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -230,8 +230,8 @@ enum ibv_rx_hash_fields { IBV_RX_HASH_DST_PORT_TCP = 1 << 5, IBV_RX_HASH_SRC_PORT_UDP = 1 << 6, IBV_RX_HASH_DST_PORT_UDP = 1 << 7, - IBV_RX_HASH_INNER = (1UL << 31), }; +#define IBV_RX_HASH_INNER (1UL << 31) struct ibv_rss_caps { uint32_t supported_qpts; @@ -1714,10 +1714,26 @@ static inline struct verbs_context *verbs_get_ctx(struct ibv_context *ctx) context)); } -#define verbs_get_ctx_op(ctx, op) ({ \ - struct verbs_context *__vctx = verbs_get_ctx(ctx); \ - (!__vctx || (__vctx->sz < sizeof(*__vctx) - offsetof(struct verbs_context, op)) || \ - !__vctx->op) ? NULL : __vctx; }) +static inline struct verbs_context *_verbs_get_ctx_op(struct ibv_context *ctx, + size_t op_off) +{ + struct verbs_context *vctx = verbs_get_ctx(ctx); + void *op; + if (!vctx) + return NULL; + + if (vctx->sz < sizeof(*vctx) - op_off) + return NULL; + + op = *((void **)((uint8_t *)vctx) + op_off); + if (!op) + return NULL; + + return vctx; +} + +#define verbs_get_ctx_op(ctx, op) \ + _verbs_get_ctx_op(ctx, offsetof(struct verbs_context, op)) /** * ibv_get_device_list - Get list of IB devices currently available diff --git a/providers/mlx4/mlx4dv.h b/providers/mlx4/mlx4dv.h index 5312a866b6e281..e8c2ce104e2acd 100644 --- a/providers/mlx4/mlx4dv.h +++ b/providers/mlx4/mlx4dv.h @@ -288,14 +288,14 @@ enum { }; enum { - MLX4_WQE_BIND_TYPE_2 = (1UL<<31), MLX4_WQE_BIND_ZERO_BASED = (1<<30), }; +#define MLX4_WQE_BIND_TYPE_2 (1UL << 31) enum { - MLX4_INLINE_SEG = 1UL << 31, MLX4_INLINE_ALIGN = 64, }; +#define MLX4_INLINE_SEG (1UL << 31) enum { MLX4_INVALID_LKEY = 0x100, @@ -304,8 +304,8 @@ enum { enum { MLX4_WQE_MW_REMOTE_READ = 1 << 29, MLX4_WQE_MW_REMOTE_WRITE = 1 << 30, - MLX4_WQE_MW_ATOMIC = 1UL << 31 }; +#define MLX4_WQE_MW_ATOMIC (1UL << 31) struct mlx4_wqe_local_inval_seg { uint64_t reserved1; diff --git a/providers/mlx5/mlx5dv.h b/providers/mlx5/mlx5dv.h index f2f5a2563287e1..01c5fa946062f2 100644 --- a/providers/mlx5/mlx5dv.h +++ b/providers/mlx5/mlx5dv.h @@ -433,9 +433,7 @@ struct mlx5_cqe64 { uint8_t op_own; }; -enum { - MLX5_TMC_SUCCESS = 0x80000000U, -}; +#define MLX5_TMC_SUCCESS (1UL << 31) enum mlx5dv_cqe_comp_res_format { MLX5DV_CQE_RES_FORMAT_HASH = 1 << 0, @@ -487,9 +485,7 @@ enum { MLX5_INVALID_LKEY = 0x100, }; -enum { - MLX5_EXTENDED_UD_AV = 0x80000000, -}; +#define MLX5_EXTENDED_UD_AV (1UL << 31) enum { MLX5_WQE_CTRL_CQ_UPDATE = 2 << 2, @@ -503,9 +499,7 @@ enum { MLX5_SEND_WQE_SHIFT = 6, }; -enum { - MLX5_INLINE_SEG = 0x80000000, -}; +#define MLX5_INLINE_SEG (1UL << 31) enum { MLX5_ETH_WQE_L3_CSUM = (1 << 6),