From patchwork Sat Mar 4 06:13:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 9603781 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 C1726601D2 for ; Sat, 4 Mar 2017 06:14:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2DC727F94 for ; Sat, 4 Mar 2017 06:14:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7EF22861F; Sat, 4 Mar 2017 06:14:30 +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=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3063F27F94 for ; Sat, 4 Mar 2017 06:14:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0E9AF802E8; Fri, 3 Mar 2017 22:14:29 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6F3EE802D3 for ; Fri, 3 Mar 2017 22:14:26 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Mar 2017 22:14:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,239,1484035200"; d="scan'208";a="55786462" Received: from omniknight.lm.intel.com ([10.232.112.53]) by orsmga002.jf.intel.com with ESMTP; 03 Mar 2017 22:14:25 -0800 From: Vishal Verma To: Subject: [ndctl PATCH v3 4/7] ccan/bitmap: fix a set of gcc warnings (with -Wshadow) Date: Fri, 3 Mar 2017 23:13:04 -0700 Message-Id: <20170304061307.13530-5-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170304061307.13530-1-vishal.l.verma@intel.com> References: <20170304061307.13530-1-vishal.l.verma@intel.com> MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Having the typedef named the same as an instance of the struct causes gcc with -Wshadow to spew warnings like: ./ccan/bitmap/bitmap.h: In function ‘bitmap_clear_bit’: ./ccan/bitmap/bitmap.h:63:45: warning: declaration of ‘bitmap’ shadows a global declaration [-Wshadow] static inline void bitmap_clear_bit(bitmap *bitmap, unsigned long n) ^~~~~~ ./ccan/bitmap/bitmap.h:23:3: note: shadowed declaration is here } bitmap; ^~~~~~ Stop these by converting the typedef to bitmap_t so that it doesn't conflict with the many places a 'bitmap' variable is used. Cc: Dan Williams Cc: Ross Zwisler Signed-off-by: Vishal Verma --- ccan/bitmap/bitmap.c | 6 +++--- ccan/bitmap/bitmap.h | 52 ++++++++++++++++++++++++++-------------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/ccan/bitmap/bitmap.c b/ccan/bitmap/bitmap.c index d812af6..554e000 100644 --- a/ccan/bitmap/bitmap.c +++ b/ccan/bitmap/bitmap.c @@ -9,7 +9,7 @@ #define BIT_ALIGN_DOWN(n) ((n) & ~(BITMAP_WORD_BITS - 1)) #define BIT_ALIGN_UP(n) BIT_ALIGN_DOWN((n) + BITMAP_WORD_BITS - 1) -void bitmap_zero_range(bitmap *bitmap, unsigned long n, unsigned long m) +void bitmap_zero_range(bitmap_t *bitmap, unsigned long n, unsigned long m) { unsigned long an = BIT_ALIGN_UP(n); unsigned long am = BIT_ALIGN_DOWN(m); @@ -34,7 +34,7 @@ void bitmap_zero_range(bitmap *bitmap, unsigned long n, unsigned long m) BITMAP_WORD(bitmap, m) &= ~bitmap_bswap(tailmask); } -void bitmap_fill_range(bitmap *bitmap, unsigned long n, unsigned long m) +void bitmap_fill_range(bitmap_t *bitmap, unsigned long n, unsigned long m) { unsigned long an = BIT_ALIGN_UP(n); unsigned long am = BIT_ALIGN_DOWN(m); @@ -76,7 +76,7 @@ static int bitmap_clz(bitmap_word w) #endif } -unsigned long bitmap_ffs(const bitmap *bitmap, +unsigned long bitmap_ffs(const bitmap_t *bitmap, unsigned long n, unsigned long m) { unsigned long an = BIT_ALIGN_UP(n); diff --git a/ccan/bitmap/bitmap.h b/ccan/bitmap/bitmap.h index 9e6c2bb..5498428 100644 --- a/ccan/bitmap/bitmap.h +++ b/ccan/bitmap/bitmap.h @@ -20,10 +20,10 @@ typedef unsigned long bitmap_word; */ typedef struct { bitmap_word w; -} bitmap; +} bitmap_t; #define BITMAP_DECLARE(_name, _nbits) \ - bitmap (_name)[BITMAP_NWORDS(_nbits)] + bitmap_t (_name)[BITMAP_NWORDS(_nbits)] static inline size_t bitmap_sizeof(unsigned long nbits) { @@ -55,47 +55,47 @@ static inline bitmap_word bitmap_bswap(bitmap_word w) #define BITMAP_TAIL(_bm, _nbits) \ (BITMAP_TAILWORD(_bm, _nbits) & BITMAP_TAILBITS(_nbits)) -static inline void bitmap_set_bit(bitmap *bitmap, unsigned long n) +static inline void bitmap_set_bit(bitmap_t *bitmap, unsigned long n) { BITMAP_WORD(bitmap, n) |= BITMAP_WORDBIT(n); } -static inline void bitmap_clear_bit(bitmap *bitmap, unsigned long n) +static inline void bitmap_clear_bit(bitmap_t *bitmap, unsigned long n) { BITMAP_WORD(bitmap, n) &= ~BITMAP_WORDBIT(n); } -static inline void bitmap_change_bit(bitmap *bitmap, unsigned long n) +static inline void bitmap_change_bit(bitmap_t *bitmap, unsigned long n) { BITMAP_WORD(bitmap, n) ^= BITMAP_WORDBIT(n); } -static inline bool bitmap_test_bit(const bitmap *bitmap, unsigned long n) +static inline bool bitmap_test_bit(const bitmap_t *bitmap, unsigned long n) { return !!(BITMAP_WORD(bitmap, n) & BITMAP_WORDBIT(n)); } -void bitmap_zero_range(bitmap *bitmap, unsigned long n, unsigned long m); -void bitmap_fill_range(bitmap *bitmap, unsigned long n, unsigned long m); +void bitmap_zero_range(bitmap_t *bitmap, unsigned long n, unsigned long m); +void bitmap_fill_range(bitmap_t *bitmap, unsigned long n, unsigned long m); -static inline void bitmap_zero(bitmap *bitmap, unsigned long nbits) +static inline void bitmap_zero(bitmap_t *bitmap, unsigned long nbits) { memset(bitmap, 0, bitmap_sizeof(nbits)); } -static inline void bitmap_fill(bitmap *bitmap, unsigned long nbits) +static inline void bitmap_fill(bitmap_t *bitmap, unsigned long nbits) { memset(bitmap, 0xff, bitmap_sizeof(nbits)); } -static inline void bitmap_copy(bitmap *dst, const bitmap *src, +static inline void bitmap_copy(bitmap_t *dst, const bitmap_t *src, unsigned long nbits) { memcpy(dst, src, bitmap_sizeof(nbits)); } #define BITMAP_DEF_BINOP(_name, _op) \ - static inline void bitmap_##_name(bitmap *dst, bitmap *src1, bitmap *src2, \ + static inline void bitmap_##_name(bitmap_t *dst, bitmap_t *src1, bitmap_t *src2, \ unsigned long nbits) \ { \ unsigned long i = 0; \ @@ -111,7 +111,7 @@ BITMAP_DEF_BINOP(andnot, & ~) #undef BITMAP_DEF_BINOP -static inline void bitmap_complement(bitmap *dst, const bitmap *src, +static inline void bitmap_complement(bitmap_t *dst, const bitmap_t *src, unsigned long nbits) { unsigned long i; @@ -120,7 +120,7 @@ static inline void bitmap_complement(bitmap *dst, const bitmap *src, dst[i].w = ~src[i].w; } -static inline bool bitmap_equal(const bitmap *src1, const bitmap *src2, +static inline bool bitmap_equal(const bitmap_t *src1, const bitmap_t *src2, unsigned long nbits) { return (memcmp(src1, src2, BITMAP_HEADBYTES(nbits)) == 0) @@ -128,7 +128,7 @@ static inline bool bitmap_equal(const bitmap *src1, const bitmap *src2, || (BITMAP_TAIL(src1, nbits) == BITMAP_TAIL(src2, nbits))); } -static inline bool bitmap_intersects(const bitmap *src1, const bitmap *src2, +static inline bool bitmap_intersects(const bitmap_t *src1, const bitmap_t *src2, unsigned long nbits) { unsigned long i; @@ -143,7 +143,7 @@ static inline bool bitmap_intersects(const bitmap *src1, const bitmap *src2, return false; } -static inline bool bitmap_subset(const bitmap *src1, const bitmap *src2, +static inline bool bitmap_subset(const bitmap_t *src1, const bitmap_t *src2, unsigned long nbits) { unsigned long i; @@ -158,7 +158,7 @@ static inline bool bitmap_subset(const bitmap *src1, const bitmap *src2, return true; } -static inline bool bitmap_full(const bitmap *bitmap, unsigned long nbits) +static inline bool bitmap_full(const bitmap_t *bitmap, unsigned long nbits) { unsigned long i; @@ -173,7 +173,7 @@ static inline bool bitmap_full(const bitmap *bitmap, unsigned long nbits) return true; } -static inline bool bitmap_empty(const bitmap *bitmap, unsigned long nbits) +static inline bool bitmap_empty(const bitmap_t *bitmap, unsigned long nbits) { unsigned long i; @@ -187,20 +187,20 @@ static inline bool bitmap_empty(const bitmap *bitmap, unsigned long nbits) return true; } -unsigned long bitmap_ffs(const bitmap *bitmap, +unsigned long bitmap_ffs(const bitmap_t *bitmap, unsigned long n, unsigned long m); /* * Allocation functions */ -static inline bitmap *bitmap_alloc(unsigned long nbits) +static inline bitmap_t *bitmap_alloc(unsigned long nbits) { return malloc(bitmap_sizeof(nbits)); } -static inline bitmap *bitmap_alloc0(unsigned long nbits) +static inline bitmap_t *bitmap_alloc0(unsigned long nbits) { - bitmap *bitmap; + bitmap_t *bitmap; bitmap = bitmap_alloc(nbits); if (bitmap) @@ -208,9 +208,9 @@ static inline bitmap *bitmap_alloc0(unsigned long nbits) return bitmap; } -static inline bitmap *bitmap_alloc1(unsigned long nbits) +static inline bitmap_t *bitmap_alloc1(unsigned long nbits) { - bitmap *bitmap; + bitmap_t *bitmap; bitmap = bitmap_alloc(nbits); if (bitmap) @@ -218,7 +218,7 @@ static inline bitmap *bitmap_alloc1(unsigned long nbits) return bitmap; } -static inline bitmap *bitmap_realloc0(bitmap *bitmap, +static inline bitmap_t *bitmap_realloc0(bitmap_t *bitmap, unsigned long obits, unsigned long nbits) { bitmap = realloc(bitmap, bitmap_sizeof(nbits)); @@ -229,7 +229,7 @@ static inline bitmap *bitmap_realloc0(bitmap *bitmap, return bitmap; } -static inline bitmap *bitmap_realloc1(bitmap *bitmap, +static inline bitmap_t *bitmap_realloc1(bitmap_t *bitmap, unsigned long obits, unsigned long nbits) { bitmap = realloc(bitmap, bitmap_sizeof(nbits));