From patchwork Fri Oct 7 22:36:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 9367751 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 4E218600C8 for ; Fri, 7 Oct 2016 22:36:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5593E297F4 for ; Fri, 7 Oct 2016 22:36:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A3242983E; Fri, 7 Oct 2016 22:36:22 +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 B4A6329800 for ; Fri, 7 Oct 2016 22:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752684AbcJGWgT (ORCPT ); Fri, 7 Oct 2016 18:36:19 -0400 Received: from quartz.orcorp.ca ([184.70.90.242]:56416 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbcJGWgQ (ORCPT ); Fri, 7 Oct 2016 18:36:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=obsidianresearch.com; s=rsa1; h=References:In-Reply-To:Message-Id:Date:Subject:To:From; bh=4O18xMBsOk20dUv7G7ya9HInaWwoD4Xr7aOATttHJdY=; b=R8OeMm/Gn90kIkrF8U6+yvo9PLa69Y1j+1J9OyoyTxHqYcHDaV8tXaTBOX+xa38cQS1TX6ncCieMdE9pbAIPrD5Yt7XW2V/eO68Okc2rTvUO3Snuhy+8tLcdUcl9u2n0LVIyS0Ewn1EGeC4cgHNQSZxvQscsPGGWmo1htT2whSc=; Received: from [10.0.0.151] (helo=jggl.edm.orcorp.ca) by quartz.orcorp.ca with esmtps (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bsdkV-0004Uv-BR; Fri, 07 Oct 2016 16:36:15 -0600 From: Jason Gunthorpe To: Doug Ledford , linux-rdma@vger.kernel.org Subject: [PATCH rdma-core 1/5] Pull uninitialized_var into util/compiler.h Date: Fri, 7 Oct 2016 16:36:08 -0600 Message-Id: <1475879772-29458-2-git-send-email-jgunthorpe@obsidianresearch.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1475879772-29458-1-git-send-email-jgunthorpe@obsidianresearch.com> References: <1475879772-29458-1-git-send-email-jgunthorpe@obsidianresearch.com> X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.151 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 The new common definition turns it off for new compilers since it is not needed and is too easy to abuse. Signed-off-by: Jason Gunthorpe Reviewed-by: Steve Wise --- CMakeLists.txt | 1 + providers/cxgb4/cq.c | 1 + providers/cxgb4/libcxgb4.h | 2 -- providers/cxgb4/qp.c | 1 + providers/mlx4/mlx4.h | 4 ---- providers/mlx4/qp.c | 1 + providers/mlx5/mlx5.h | 4 ---- providers/mlx5/qp.c | 1 + util/CMakeLists.txt | 3 +++ util/compiler.h | 18 ++++++++++++++++++ 10 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 util/CMakeLists.txt create mode 100644 util/compiler.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b0864da660fc..1611e90d7933 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,6 +253,7 @@ configure_file("${BUILDLIB}/config.h.in" "${BUILD_INCLUDE}/config.h" ESCAPE_QUOT #------------------------- # Sub-directories add_subdirectory(ccan) +add_subdirectory(util) # Libraries add_subdirectory(libibumad) add_subdirectory(libibumad/man) diff --git a/providers/cxgb4/cq.c b/providers/cxgb4/cq.c index 1ed7dfdb88d4..5f662ac49d0c 100644 --- a/providers/cxgb4/cq.c +++ b/providers/cxgb4/cq.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "libcxgb4.h" #include "cxgb4-abi.h" diff --git a/providers/cxgb4/libcxgb4.h b/providers/cxgb4/libcxgb4.h index 4c8383209287..9a4bc98f34e9 100644 --- a/providers/cxgb4/libcxgb4.h +++ b/providers/cxgb4/libcxgb4.h @@ -264,6 +264,4 @@ void dump_state(); extern int stall_to; #endif -#define uninitialized_var(x) x = x - #endif /* IWCH_H */ diff --git a/providers/cxgb4/qp.c b/providers/cxgb4/qp.c index 384bf11369ac..95b459a1a9b4 100644 --- a/providers/cxgb4/qp.c +++ b/providers/cxgb4/qp.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "libcxgb4.h" #ifdef STATS diff --git a/providers/mlx4/mlx4.h b/providers/mlx4/mlx4.h index 95a6521c457b..a2d39e169c15 100644 --- a/providers/mlx4/mlx4.h +++ b/providers/mlx4/mlx4.h @@ -43,10 +43,6 @@ #define MLX4_PORTS_NUM 2 -#ifndef uninitialized_var -#define uninitialized_var(x) x = x -#endif - #include #define PFX "mlx4: " diff --git a/providers/mlx4/qp.c b/providers/mlx4/qp.c index 4b5acd71108e..268fb7dc83dd 100644 --- a/providers/mlx4/qp.c +++ b/providers/mlx4/qp.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "mlx4.h" #include "doorbell.h" diff --git a/providers/mlx5/mlx5.h b/providers/mlx5/mlx5.h index f8674c7a90db..cb65429b51f7 100644 --- a/providers/mlx5/mlx5.h +++ b/providers/mlx5/mlx5.h @@ -48,10 +48,6 @@ #define unlikely(x) __builtin_expect((x), 0) #endif -#ifndef uninitialized_var -#define uninitialized_var(x) x = x -#endif - #include #ifdef HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE diff --git a/providers/mlx5/qp.c b/providers/mlx5/qp.c index 04abe1588d6e..e82b1a0bebc3 100644 --- a/providers/mlx5/qp.c +++ b/providers/mlx5/qp.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "mlx5.h" #include "doorbell.h" diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt new file mode 100644 index 000000000000..1cda8905d8f4 --- /dev/null +++ b/util/CMakeLists.txt @@ -0,0 +1,3 @@ +publish_internal_headers(util + compiler.h + ) diff --git a/util/compiler.h b/util/compiler.h new file mode 100644 index 000000000000..9b57e048df4b --- /dev/null +++ b/util/compiler.h @@ -0,0 +1,18 @@ +/* GPLv2 or OpenIB.org BSD (MIT) See COPYING file */ +#ifndef UTIL_COMPILER_H +#define UTIL_COMPILER_H + +/* Use to tag a variable that causes compiler warnings. Use as: + int uninitialized_var(sz) + + This is only enabled for old compilers. gcc 6.x and beyond have excellent + static flow analysis. If code solicits a warning from 6.x it is almost + certainly too complex for a human to understand. +*/ +#if __GNUC__ >= 6 || defined(__clang__) +#define uninitialized_var(x) x +#else +#define uninitialized_var(x) x = x +#endif + +#endif