Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp190803imm; Thu, 26 Jul 2018 01:36:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeMGktvxi5nqeust329UI6gY30/ax15imwFdDk4N/6dw4hEKD4NGt7PEgol3Fsqcq+lnK65 X-Received: by 2002:a17:902:6b46:: with SMTP id g6-v6mr1070654plt.251.1532594213872; Thu, 26 Jul 2018 01:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532594213; cv=none; d=google.com; s=arc-20160816; b=NxPy6pxOSTPjFzllOusregYGKSQfh6+i3n9guBxQJkNyi5ycqfHJ1t2YHrj1o6ElqU jaINuA03mT97xzfnoUz/Lgn6KdayW61qHbyTV0RAEXvtcIyHlSldNbMxDuuDIcunlkcd XptlM48D+lsBJhnm2rBhsAqbEgcFSIMdCqhwteHKDgmxV51Zrf1tIEGXYfPE57j0dkzT cwVgN1qI0Qgm42Y+qbTlr/wRLMgbSexpDNNVUg0/UEBnAdpDk51TRkyJDhnPs+c+xoMc IBiY4R8lcP1kvldJPIMWctvTQkoW0BAt03DcT67EDGd1D5Wo82v+MoTXTpbbTwU3xCAy qFuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2Kn5vA/s5dFYGcXrtK36izmHXg3IyYtJcc91vxU+kek=; b=IKm8BiwXQ90L5bf+ItG4Oeg5WguA5CCVVqcPfDhAB7AMhrRlquYlApgsTW53tehJZL VXU1g03w9YBn+/wdeVn1E4UpyVB54pWlKDRgWY8V5N8Me7alfj0JpZlCMFcYPIw9xLea P0ghS4yQ2v+7s4/Wm/CqMr0lnw3Egzn51gVDL/uoh2Lh3UtEFgN6xLND9EXXTVOzYU0/ lQhsxyNSTeARnqpzF8CVlh1XCAtNSlureGEnraVKcef6sLI/pmIX406+hBtPaxhPkyGq M2T7dYfW2ZZ2YyOaQUygZziJsDqDCgXqBEG7qhJfyIfYOsFXv1fnarmTupVRaims0KkJ JMkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1-v6si741704pld.218.2018.07.26.01.36.39; Thu, 26 Jul 2018 01:36:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728990AbeGZJv2 (ORCPT + 99 others); Thu, 26 Jul 2018 05:51:28 -0400 Received: from mga09.intel.com ([134.134.136.24]:65330 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727951AbeGZJv1 (ORCPT ); Thu, 26 Jul 2018 05:51:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2018 01:35:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,404,1526367600"; d="scan'208";a="74654639" Received: from devel-ww.sh.intel.com ([10.239.48.110]) by fmsmga004.fm.intel.com with ESMTP; 26 Jul 2018 01:35:39 -0700 From: Wei Wang To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, ynorov@caviumnetworks.com, corbet@lwn.net, linux@rasmusvillemoes.dk Cc: dgilbert@redhat.com, mawilcox@microsoft.com, wei.w.wang@intel.com Subject: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK Date: Thu, 26 Jul 2018 16:07:51 +0800 Message-Id: <1532592471-21177-1-git-send-email-wei.w.wang@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The existing BITMAP_LAST_WORD_MASK macro returns 0xffffffff if nbits is 0. This patch changes the macro to return 0 when there is no bit needs to be masked. Signed-off-by: Wei Wang Cc: Andrew Morton Cc: Rasmus Villemoes Cc: Yury Norov --- include/linux/bitmap.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 1ee46f4..12af3d7 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -194,7 +194,10 @@ extern int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, int nmaskbits); #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) -#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) +#define BITMAP_LAST_WORD_MASK(nbits) \ +( \ + nbits ? (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) : 0 \ +) #define small_const_nbits(nbits) \ (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) -- 2.7.4