From patchwork Thu Oct 15 06:54:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7402911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BFE9BBEEA4 for ; Thu, 15 Oct 2015 06:57:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CABFA20852 for ; Thu, 15 Oct 2015 06:57:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB24F20851 for ; Thu, 15 Oct 2015 06:57:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmcS0-0003py-DU; Thu, 15 Oct 2015 06:55:44 +0000 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmcRx-0003ab-5K for linux-arm-kernel@lists.infradead.org; Thu, 15 Oct 2015 06:55:42 +0000 Received: by wicgb1 with SMTP id gb1so258626934wic.1 for ; Wed, 14 Oct 2015 23:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=SOctsC09yJ6tkCe2Z1f/KLLIsw8nz41MNjAqaNUQYz8=; b=bR9zH//4jM0Fy/0n9v0qnYla+O9ZvrZlLF4148KdqNyQPflQW9W1nQxZikoH29BKUG /RGX3GBhttOWi6Pc1UeEhoSC9etb+GylM8FPE1ZNEDwibABWd1WODekrh9/dlWBRWiZb Q0JfcY0zKQNzYAqQf7LwzT5eoRwNHDMzPNcrjrJRedfLaoumYLhNW2IQRim5882IXeTp 6IbcRIAYuI2nIR0vHsf26jaFn/cTHMpvUKv+tOn4hUmJxq9TTul14bmRY87ddLWqS22N 2DL/O7y6GV3b7Efhe292dnXpLAklX+ecvuB3kb5atb/gkBMrhjuAjLRiF/iTCo9Ma+JC 7Xkw== X-Received: by 10.194.249.100 with SMTP id yt4mr10067009wjc.74.1444892118439; Wed, 14 Oct 2015 23:55:18 -0700 (PDT) Received: from Red.local (ANice-651-1-191-74.w83-197.abo.wanadoo.fr. [83.197.127.74]) by smtp.googlemail.com with ESMTPSA id bd4sm8592520wjb.15.2015.10.14.23.55.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Oct 2015 23:55:17 -0700 (PDT) From: LABBE Corentin To: clabbe.montjoie@gmail.com, linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, yamada.masahiro@socionext.com Subject: [PATCH] arm: fix the return value of find_first{_zero}_bit Date: Thu, 15 Oct 2015 08:54:59 +0200 Message-Id: <1444892115-24784-1-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.4.9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151014_235541_379810_BAEEA6F6 X-CRM114-Status: GOOD ( 13.56 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Building linux with W=1 on arm give me this warning; In file included from ../include/linux/nodemask.h:92:0, from ../include/linux/mmzone.h:16, from ../include/linux/gfp.h:5, from ../include/linux/kmod.h:22, from ../include/linux/module.h:13, from net/netfilter/xt_nat.mod.c:1: ../include/linux/bitmap.h: In function 'bitmap_empty': ../include/linux/bitmap.h:287:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] return find_first_bit(src, nbits) == nbits; ../include/linux/bitmap.h: In function 'bitmap_full': ../include/linux/bitmap.h:295:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] return find_first_zero_bit(src, nbits) == nbits; The problem is that find_first{_zero}_bit() return type is unsigned long on majority of arch. Since find_first{_zero}_bit cannot return negative value, unsigned long is the best return type. After some read, it seems that find_next_bit_[lb]e/_find_next_zero_bit_[lb]e are also incorectly set as return int. This patch fix the return type of all thoses functions. Signed-off-by: LABBE Corentin --- arch/arm/include/asm/bitops.h | 22 +++++++++++----------- arch/arm/lib/findbit.S | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h index e943e6c..868414b 100644 --- a/arch/arm/include/asm/bitops.h +++ b/arch/arm/include/asm/bitops.h @@ -159,18 +159,18 @@ extern int _test_and_change_bit(int nr, volatile unsigned long * p); /* * Little endian assembly bitops. nr = 0 -> byte 0 bit 0. */ -extern int _find_first_zero_bit_le(const void * p, unsigned size); -extern int _find_next_zero_bit_le(const void * p, int size, int offset); -extern int _find_first_bit_le(const unsigned long *p, unsigned size); -extern int _find_next_bit_le(const unsigned long *p, int size, int offset); +extern unsigned long _find_first_zero_bit_le(const void *p, unsigned size); +extern unsigned long _find_next_zero_bit_le(const void *p, int size, int offset); +extern unsigned long _find_first_bit_le(const unsigned long *p, unsigned size); +extern unsigned long _find_next_bit_le(const unsigned long *p, int size, int offset); /* * Big endian assembly bitops. nr = 0 -> byte 3 bit 0. */ -extern int _find_first_zero_bit_be(const void * p, unsigned size); -extern int _find_next_zero_bit_be(const void * p, int size, int offset); -extern int _find_first_bit_be(const unsigned long *p, unsigned size); -extern int _find_next_bit_be(const unsigned long *p, int size, int offset); +extern unsigned long _find_first_zero_bit_be(const void *p, unsigned size); +extern unsigned long _find_next_zero_bit_be(const void *p, int size, int offset); +extern unsigned long _find_first_bit_be(const unsigned long *p, unsigned size); +extern unsigned long _find_next_bit_be(const unsigned long *p, int size, int offset); #ifndef CONFIG_SMP /* @@ -317,19 +317,19 @@ static inline unsigned long __ffs(unsigned long x) #ifdef __ARMEB__ -static inline int find_first_zero_bit_le(const void *p, unsigned size) +static inline unsigned long find_first_zero_bit_le(const void *p, unsigned size) { return _find_first_zero_bit_le(p, size); } #define find_first_zero_bit_le find_first_zero_bit_le -static inline int find_next_zero_bit_le(const void *p, int size, int offset) +static inline unsigned long find_next_zero_bit_le(const void *p, int size, int offset) { return _find_next_zero_bit_le(p, size, offset); } #define find_next_zero_bit_le find_next_zero_bit_le -static inline int find_next_bit_le(const void *p, int size, int offset) +static inline unsigned long find_next_bit_le(const void *p, int size, int offset) { return _find_next_bit_le(p, size, offset); } diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S index 7848780..b4f6aec 100644 --- a/arch/arm/lib/findbit.S +++ b/arch/arm/lib/findbit.S @@ -19,7 +19,7 @@ /* * Purpose : Find a 'zero' bit - * Prototype: int find_first_zero_bit(void *addr, unsigned int maxbit); + * Prototype: unsigned long find_first_zero_bit(void *addr, unsigned int maxbit); */ ENTRY(_find_first_zero_bit_le) teq r1, #0 @@ -40,7 +40,7 @@ ENDPROC(_find_first_zero_bit_le) /* * Purpose : Find next 'zero' bit - * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset) + * Prototype: unsigned long find_next_zero_bit(void *addr, unsigned int maxbit, int offset) */ ENTRY(_find_next_zero_bit_le) teq r1, #0 @@ -60,7 +60,7 @@ ENDPROC(_find_next_zero_bit_le) /* * Purpose : Find a 'one' bit - * Prototype: int find_first_bit(const unsigned long *addr, unsigned int maxbit); + * Prototype: unsigned long find_first_bit(const unsigned long *addr, unsigned int maxbit); */ ENTRY(_find_first_bit_le) teq r1, #0 @@ -81,7 +81,7 @@ ENDPROC(_find_first_bit_le) /* * Purpose : Find next 'one' bit - * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset) + * Prototype: unsigned long find_next_zero_bit(void *addr, unsigned int maxbit, int offset) */ ENTRY(_find_next_bit_le) teq r1, #0