Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp219943imw; Fri, 8 Jul 2022 01:28:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t6TelMyhPyRMkrmEy3mNI4UBfXeVhhhVbO+dv5uDjrewQlg/GGvlse/j9LM2iUtTIs6wVJ X-Received: by 2002:a17:90a:a384:b0:1ef:da60:9577 with SMTP id x4-20020a17090aa38400b001efda609577mr7501286pjp.36.1657268931992; Fri, 08 Jul 2022 01:28:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657268931; cv=none; d=google.com; s=arc-20160816; b=AnvWVOb6ePRpQS9c8P8M8IvlCGIl6VeQKtCwu8B/6n82pEVLpQv1myLLBlj48hB84W kIQd+kCMQxjlxKMqJAaYrCI+tiI4mjFJjN3h9BN8WhqXnw06Q8ZRVVm/v3pBFBXZTb2u AYsG16eNd4aSI8MCxY0w9mUejSX7JzrnvKTKV2+FstrUrAZDYB31GIiWkYpJGooj0eOK szaLCdPJF61zQ3F/4jWIMNH5mln5ktTIvMBwuOSSEQt2QzYeOs1J2obuxiqDHiyb2AZP L970vmQ2quEtM9LMSFBMwsjIe0QeptuwYq8NOq7JFem3jbJ0wbMKu20ddU8pMPdNge8T 64xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=qXmKD/+3eEp/JehzTTDmEx0gUqXgcXuJFA83Mhp25GM=; b=U+KOl8H1XrPfOmZVcWep3GVf0Pnh+TFcSe/TWf8JSvaLaOJpKtvn1i7OhrU4UZX3pA JIS0kwNshEA3/zEKVcrCaG5wPm+O+4sV1fsFQIZVeMFSPy+fGx468QmDNJCvb7Pc0ALo rNap29VPCjtjqphV2mYnZer/5O5LNoyCM232yfcX4puqlbrFjygAxCXEs6U/RpdN26OZ Dh8qwMeyTc7o7G859p0vW4tN2E4kJ2Vd7VeGDQAwOr+koCSUIHffONJUmg1c/V/0X+Oo 7ZBPIDb8LEZp9IdRR5DOgbfNZ1JH/Z4Q8gYFembuKUUgHHCJv9TS7veVKY0eRqn+JeKo 33uA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c23-20020aa79537000000b005283dd63ad1si25562996pfp.334.2022.07.08.01.28.37; Fri, 08 Jul 2022 01:28:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237338AbiGHHxo (ORCPT + 99 others); Fri, 8 Jul 2022 03:53:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236895AbiGHHxl (ORCPT ); Fri, 8 Jul 2022 03:53:41 -0400 Received: from mx1.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBBB21D308 for ; Fri, 8 Jul 2022 00:53:38 -0700 (PDT) Received: from localhost.localdomain (ip5f5aeb4e.dynamic.kabel-deutschland.de [95.90.235.78]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id C942B61EA1929; Fri, 8 Jul 2022 09:53:35 +0200 (CEST) From: Paul Menzel To: Yury Norov , Andy Shevchenko , Rasmus Villemoes Cc: Paul Menzel , linux-kernel@vger.kernel.org Subject: [PATCH v2] lib/bitmap: Make parameter len unsigned Date: Fri, 8 Jul 2022 09:52:40 +0200 Message-Id: <20220708075239.9057-1-pmenzel@molgen.mpg.de> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The length is non-negative, so make it unsigned. Signed-off-by: Paul Menzel --- v2: Update signature in header file include/linux/bitmap.h | 2 +- lib/bitmap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 2e6cd5681040..feaf84cbc487 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -164,7 +164,7 @@ bool __bitmap_intersects(const unsigned long *bitmap1, bool __bitmap_subset(const unsigned long *bitmap1, const unsigned long *bitmap2, unsigned int nbits); int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); -void __bitmap_set(unsigned long *map, unsigned int start, int len); +void __bitmap_set(unsigned long *map, unsigned int start, unsigned int len); void __bitmap_clear(unsigned long *map, unsigned int start, int len); unsigned long bitmap_find_next_zero_area_off(unsigned long *map, diff --git a/lib/bitmap.c b/lib/bitmap.c index b18e31ea6e66..0746beb336df 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -348,14 +348,14 @@ int __bitmap_weight(const unsigned long *bitmap, unsigned int bits) } EXPORT_SYMBOL(__bitmap_weight); -void __bitmap_set(unsigned long *map, unsigned int start, int len) +void __bitmap_set(unsigned long *map, unsigned int start, unsigned int len) { unsigned long *p = map + BIT_WORD(start); const unsigned int size = start + len; int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG); unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start); - while (len - bits_to_set >= 0) { + while (len >= bits_to_set) { *p |= mask_to_set; len -= bits_to_set; bits_to_set = BITS_PER_LONG; -- 2.36.1