From nobody Sun Apr 19 00:27:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31BDDC433EF for ; Thu, 7 Jul 2022 21:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236295AbiGGVv5 (ORCPT ); Thu, 7 Jul 2022 17:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbiGGVv4 (ORCPT ); Thu, 7 Jul 2022 17:51:56 -0400 Received: from mx1.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC97B4D15C for ; Thu, 7 Jul 2022 14:51:54 -0700 (PDT) Received: from localhost.localdomain (ip5f5aedb6.dynamic.kabel-deutschland.de [95.90.237.182]) (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 5E3FE61EA192C; Thu, 7 Jul 2022 23:51:51 +0200 (CEST) From: Paul Menzel To: Yury Norov , Andy Shevchenko , Rasmus Villemoes Cc: Paul Menzel , linux-kernel@vger.kernel.org Subject: [PATCH] lib/bitmap: Make length parameter `len` unsigned Date: Thu, 7 Jul 2022 23:50:52 +0200 Message-Id: <20220707215051.5664-1-pmenzel@molgen.mpg.de> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The length is non-negative, so make it unsigned, and adapt while condition accordingly. Signed-off-by: Paul Menzel --- lib/bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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, unsi= gned int bits) } EXPORT_SYMBOL(__bitmap_weight); =20 -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 =3D map + BIT_WORD(start); const unsigned int size =3D start + len; int bits_to_set =3D BITS_PER_LONG - (start % BITS_PER_LONG); unsigned long mask_to_set =3D BITMAP_FIRST_WORD_MASK(start); =20 - while (len - bits_to_set >=3D 0) { + while (len >=3D bits_to_set) { *p |=3D mask_to_set; len -=3D bits_to_set; bits_to_set =3D BITS_PER_LONG; --=20 2.36.1