From patchwork Tue May 17 21:22:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 12852970 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 5F7D4C433FE for ; Tue, 17 May 2022 21:22:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232539AbiEQVWl (ORCPT ); Tue, 17 May 2022 17:22:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbiEQVWi (ORCPT ); Tue, 17 May 2022 17:22:38 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 577843EBBC for ; Tue, 17 May 2022 14:22:37 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id pq9-20020a17090b3d8900b001df622bf81dso78875pjb.3 for ; Tue, 17 May 2022 14:22:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uepQWFj4p9vvzxFu0J6TcubCn573rdrWQyzAe1PX5G0=; b=Dy8WRIdSNRo8VedfCaJuzfBJKdEveNueIl6h1m5H7A7GpqO1VFIRFp3xhZUt4FRFO2 W3chIK/93Xpm3hii/SpKvczGW2Df+zSEX9NG0JxKOF5ehz9I6/07cUIMW8Itr/trzr0M cwelbmHTgyV63Lvehq8qPp3YvsYj2q4YKkG94= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uepQWFj4p9vvzxFu0J6TcubCn573rdrWQyzAe1PX5G0=; b=uw2AaPLP26+x78DBAuJnhMzCPEFDQnQL6hFLePlPaLCizPf1Kfej6qIsy/HM3WHj+k PkgSWXk6nF+QoVFJdxCCNM3DysQ+ItTVJ5ItvpjlO6cK5nT3i1Mho+OP7AJzfZZrduPt u1ojx9+uYoBmnr7wmQYZHbK7/4w2IM4PS1Sj0MjqWcts7Ujy5gwoSWcXw6UZIJvmcdeY 0EE6e+AcXTWG4H5X1eIOsV24ymSGEWxZ4u5Um88uaTogguTOmPP57Kp/C8QYbOv4OgHj E5q41eAP2/k4zl5lxlRf6z47N6Qs7htFL1Cf08UjwGvSAjAjYPDxmqlgqAs8bChWr4Xd +/yw== X-Gm-Message-State: AOAM532WMNNtGlso9KeolAvxDA27e23yvqJZAPW25mQjp8in/B+NC/OU GxBPdxgu6+A0hRlx1ZWmxDL4mQ== X-Google-Smtp-Source: ABdhPJweAH8JloCK5hClRf6c3ajBQArCtatGzkr3y/VhlYkSwTwIXhf6BZTUnYx7czoMf94YW2ba7w== X-Received: by 2002:a17:902:e88b:b0:161:79f6:42a8 with SMTP id w11-20020a170902e88b00b0016179f642a8mr12134677plg.131.1652822556812; Tue, 17 May 2022 14:22:36 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c18-20020aa78c12000000b0051815121e2csm173244pfd.164.2022.05.17.14.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 14:22:36 -0700 (PDT) From: Kees Cook To: Yury Norov Cc: Kees Cook , Rasmus Villemoes , Christophe de Dinechin , Alexey Dobriyan , Andy Shevchenko , Andrew Morton , Zhen Lei , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 1/2] bitmap: Fix return values to be unsigned Date: Tue, 17 May 2022 14:22:33 -0700 Message-Id: <20220517212234.868181-2-keescook@chromium.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220517212234.868181-1-keescook@chromium.org> References: <20220517212234.868181-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4867; h=from:subject; bh=t1Ia3Wci2ZC0qKVzbH7/1fuiBHOoRUGjZ00k0amlW8s=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBihBIZqREFg+WTcBpL6MUHMvjMCQvDFYx6X+rk1V+U Gfh0dBCJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYoQSGQAKCRCJcvTf3G3AJjViD/ 9f1ik1XrhV2v/KFyUIvCtGUo+ArmKp4K2jNlNf35LGXiM+8iSIjhSs1EN7JhqLROfHWaHn2dNq4cXt 8w94o/An4USxo2OoLLjf9mzQugXU5qTu8ydNHBa1LMsMHrMu0RAY3GvX0uSFXMIUsEJwnpCNG2U96/ KRDJ8AWORRxQ04h16NO1eoy9kkC11cSvlUu2/VpJ4VKNsaFRoFj5vQ9oGwkgAe1hpI5xh4NIGEX+/F MnvebF4T7rMmbVwCqytI3XZ1EPNdXTDgUASc171ttgbDa2c3LndKkScU7lMXUPMrfn7XD5ZrsoBXjZ n1spwQS2Hyx5VpayIt4Ic+xVZ824koHfdV4iis7NcL1LvIzfLM3QUl0or6OErw/OSnc3eHtgDeAhts jcbPOY4EQugpZZU6kRiLBAzscPqFgtXAVa91NFnJdn2mis/nzq2Cy0cMUHWSh+fABrhyseOzIocoFB /153hvmLGdAvqBC3ff6nimVTs5zsD+HjMD+z5+ZqTqkCKBIgSTs5nMgkM1x2jR4YIhc5io2fNmLBiD RTA95RLJOFULKni+cWDE8WBUWbI+mqKqUWBLUfopuf5nljGHYCx9mNiyzP+Qy9qlz1swYv+uRLIa7G Lj6M/LMxDxM4/BsptiJruOlV0VNsu1PgR6ZlkESQCSikTl56D57gVdLGFyoQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Both nodemask and bitmap routines had mixed return values that provided potentially signed return values that could never happen. This was leading to the compiler getting confusing about the range of possible return values (it was thinking things could be negative where they could not be). In preparation for fixing nodemask, fix all the bitmap routines that should be returning unsigned (or bool) values. Cc: Yury Norov Cc: Rasmus Villemoes Cc: Christophe de Dinechin Cc: Alexey Dobriyan Cc: Andy Shevchenko Cc: Andrew Morton Cc: Zhen Lei Signed-off-by: Kees Cook --- include/linux/bitmap.h | 14 +++++++------- lib/bitmap.c | 28 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 7dba0847510c..381735c2f2f1 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -132,8 +132,8 @@ unsigned long *devm_bitmap_zalloc(struct device *dev, * lib/bitmap.c provides these functions: */ -int __bitmap_equal(const unsigned long *bitmap1, - const unsigned long *bitmap2, unsigned int nbits); +bool __bitmap_equal(const unsigned long *bitmap1, + const unsigned long *bitmap2, unsigned int nbits); bool __pure __bitmap_or_equal(const unsigned long *src1, const unsigned long *src2, const unsigned long *src3, @@ -157,10 +157,10 @@ int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, void __bitmap_replace(unsigned long *dst, const unsigned long *old, const unsigned long *new, const unsigned long *mask, unsigned int nbits); -int __bitmap_intersects(const unsigned long *bitmap1, - const unsigned long *bitmap2, unsigned int nbits); -int __bitmap_subset(const unsigned long *bitmap1, - const unsigned long *bitmap2, unsigned int nbits); +bool __bitmap_intersects(const unsigned long *bitmap1, + const unsigned long *bitmap2, unsigned int nbits); +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_clear(unsigned long *map, unsigned int start, int len); @@ -331,7 +331,7 @@ static inline void bitmap_complement(unsigned long *dst, const unsigned long *sr #endif #define BITMAP_MEM_MASK (BITMAP_MEM_ALIGNMENT - 1) -static inline int bitmap_equal(const unsigned long *src1, +static inline bool bitmap_equal(const unsigned long *src1, const unsigned long *src2, unsigned int nbits) { if (small_const_nbits(nbits)) diff --git a/lib/bitmap.c b/lib/bitmap.c index 0d5c2ece0bcb..b57dafe13eec 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -45,19 +45,19 @@ * for the best explanations of this ordering. */ -int __bitmap_equal(const unsigned long *bitmap1, +bool __bitmap_equal(const unsigned long *bitmap1, const unsigned long *bitmap2, unsigned int bits) { unsigned int k, lim = bits/BITS_PER_LONG; for (k = 0; k < lim; ++k) if (bitmap1[k] != bitmap2[k]) - return 0; + return false; if (bits % BITS_PER_LONG) if ((bitmap1[k] ^ bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits)) - return 0; + return false; - return 1; + return true; } EXPORT_SYMBOL(__bitmap_equal); @@ -303,33 +303,33 @@ void __bitmap_replace(unsigned long *dst, } EXPORT_SYMBOL(__bitmap_replace); -int __bitmap_intersects(const unsigned long *bitmap1, - const unsigned long *bitmap2, unsigned int bits) +bool __bitmap_intersects(const unsigned long *bitmap1, + const unsigned long *bitmap2, unsigned int bits) { unsigned int k, lim = bits/BITS_PER_LONG; for (k = 0; k < lim; ++k) if (bitmap1[k] & bitmap2[k]) - return 1; + return true; if (bits % BITS_PER_LONG) if ((bitmap1[k] & bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits)) - return 1; - return 0; + return true; + return false; } EXPORT_SYMBOL(__bitmap_intersects); -int __bitmap_subset(const unsigned long *bitmap1, - const unsigned long *bitmap2, unsigned int bits) +bool __bitmap_subset(const unsigned long *bitmap1, + const unsigned long *bitmap2, unsigned int bits) { unsigned int k, lim = bits/BITS_PER_LONG; for (k = 0; k < lim; ++k) if (bitmap1[k] & ~bitmap2[k]) - return 0; + return false; if (bits % BITS_PER_LONG) if ((bitmap1[k] & ~bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits)) - return 0; - return 1; + return false; + return true; } EXPORT_SYMBOL(__bitmap_subset); From patchwork Tue May 17 21:22:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 12852972 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 5D963C433EF for ; Tue, 17 May 2022 21:22:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbiEQVWn (ORCPT ); Tue, 17 May 2022 17:22:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231931AbiEQVWj (ORCPT ); Tue, 17 May 2022 17:22:39 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B81413ED04 for ; Tue, 17 May 2022 14:22:37 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id pq9-20020a17090b3d8900b001df622bf81dso78896pjb.3 for ; Tue, 17 May 2022 14:22:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Owv008S1mnLnQx4FX8fpU4Ogq2/9KsKFYrwKU2ohc0s=; b=io8GOq5QwWCqnCuLT+1nCJ9FopsU1HXbidc5NhnARs0p4FdzVHHJjf7h5IWdN1NrGG 2srzB5atQM7bC4NRoPB7tLzpBr7ViHb4eWTOKYiM0AMI7P82TIPu3TVy3S+z0QpNtfmx NxVstHKxZO/S10C8ezhDcUJSbQNoSbB1V/dCY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Owv008S1mnLnQx4FX8fpU4Ogq2/9KsKFYrwKU2ohc0s=; b=7/eQQTkEq+uwgqQ4K9Z0lDFddsJzF8XJJptR+vCQswXwXD8i5EeS4YrvhS6N/ET01h MPaGPAGRVFd2R0RuJ/gZd7riQYeukWDsEma8Gmqm396eZIJv2/ola2U377QWj5dLc6F1 6sq/7eexj2VMkoC++fQBTwvG0izwtZS4rQ7KpYRxSvyybA1QixcFu07AXOtcvNNM/Kk4 /7TPinGfNvmxKsJPl9J/N3qOQ70gZoVhocT0ke6aQEQah8kwMYmSBtisV0XZGPxqzCd0 zJTjmcdcwN9/kklO7EPH02KGbAgFRSua1k3PbmD94NOuTMD7zhEBToznCZSf9t2S2Acy 2kPw== X-Gm-Message-State: AOAM533v5YL3WnYCh+b4RbEDAJDtz8vCqQDL7fGZTyti+K1wzuekMt+d SD5coEqgTOuVvHYi0zO3NvsdmqYM+uvoAg== X-Google-Smtp-Source: ABdhPJzdVTqM1irj9jTRkg3UyFQYPFRlJ8NhW8Dng3RLH2PK0kV++JassBwnFUKB5cLTQVVx/JoWSA== X-Received: by 2002:a17:902:f605:b0:14d:9e11:c864 with SMTP id n5-20020a170902f60500b0014d9e11c864mr24456412plg.54.1652822557207; Tue, 17 May 2022 14:22:37 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d1-20020a62f801000000b0050dd876f5f8sm203763pfh.49.2022.05.17.14.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 14:22:36 -0700 (PDT) From: Kees Cook To: Yury Norov Cc: Kees Cook , Christophe de Dinechin , Alexey Dobriyan , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , Zhen Lei , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 2/2] nodemask: Fix return values to be unsigned Date: Tue, 17 May 2022 14:22:34 -0700 Message-Id: <20220517212234.868181-3-keescook@chromium.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220517212234.868181-1-keescook@chromium.org> References: <20220517212234.868181-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7372; h=from:subject; bh=LEXAUG9zqc/TgnUiqrSc+AaEdVOWiNU6eYa3b0/wsVQ=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBihBIZQvrvPnNWKFXJhk3vDVY5ef5M4Ty5pllPp/kU O1NFf5WJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYoQSGQAKCRCJcvTf3G3AJqWpD/ 9IKqaBhfkWChgQnMTwGTrA5vz+0196CCmM7qEcpJMTFbysQyFUXOAixfSMt2bE1z5i3KcLCAqUVJfo g+C/1KrRv7V7JltQueFM9plElJ2agTQWaq7uatZlQ8O6pgaVNXurxhR/lmtuCSC2Xr8RlsHZVO4s5b VoJei7eGkws+kTPox+v9EybInB+l1wRcPDdG/3UCsQYEL9io0wS3uxDZqltEUuy/JbCv4UGV4eADu2 pJsWW5sBlRa7HMtF2gxLz9xQVG+kC3u275KD7bGs39VjmtYsQgY+qvqL9gHItsLITTmADYE1up1tqv BF47ajG70QdTFC5LuOyIvHpPOmHDSP8TjFJlMeUP6j85PezSZ91lpe8dzkxjxdG0gPK8K8Y3tewpJt 4RGMkuxaPtURmqDFORkUfcs3bflNSJxuAE34csEuu6fugToMmJvzMSIMXalkA2YuMghHVkv9/9zNNC BqsgiEAJdZVJkwt8FYILZQch54SAjT4qWhinaJpz8ICU6mOeeGAG0T+qHyByPNHsCUxUJw7OriNKH5 Cy26o/ZD+jVkf11B2skTjJ3sR6+UkJ20MXBQQk5XSWIsMl4iAELTo4IuSziANCN4H0GX9QppJM2fvm u0l5nWtY0wzZKYGA0VJxvIQzuFftwmn+icIvNibyfxbr1lE98coCTr0rde6w== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org The nodemask routines had mixed return values that provided potentially signed return values that could never happen. This was leading to the compiler getting confusing about the range of possible return values (it was thinking things could be negative where they could not be). Fix all the nodemask routines that should be returning unsigned (or bool) values. Silences: mm/swapfile.c: In function ‘setup_swap_info’: mm/swapfile.c:2291:47: error: array subscript -1 is below array bounds of ‘struct plist_node[]’ [-Werror=array-bounds] 2291 | p->avail_lists[i].prio = 1; | ~~~~~~~~~~~~~~^~~ In file included from mm/swapfile.c:16: ./include/linux/swap.h:292:27: note: while referencing ‘avail_lists’ 292 | struct plist_node avail_lists[]; /* | ^~~~~~~~~~~ Reported-by: Christophe de Dinechin Link: https://lore.kernel.org/lkml/20220414150855.2407137-3-dinechin@redhat.com/ Cc: Alexey Dobriyan Cc: Yury Norov Cc: Andy Shevchenko Cc: Rasmus Villemoes Cc: Andrew Morton Cc: Zhen Lei Signed-off-by: Kees Cook --- include/linux/nodemask.h | 38 +++++++++++++++++++------------------- lib/nodemask.c | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h index 567c3ddba2c4..2c39663c3407 100644 --- a/include/linux/nodemask.h +++ b/include/linux/nodemask.h @@ -42,11 +42,11 @@ * void nodes_shift_right(dst, src, n) Shift right * void nodes_shift_left(dst, src, n) Shift left * - * int first_node(mask) Number lowest set bit, or MAX_NUMNODES - * int next_node(node, mask) Next node past 'node', or MAX_NUMNODES - * int next_node_in(node, mask) Next node past 'node', or wrap to first, + * unsigned int first_node(mask) Number lowest set bit, or MAX_NUMNODES + * unsigend int next_node(node, mask) Next node past 'node', or MAX_NUMNODES + * unsigned int next_node_in(node, mask) Next node past 'node', or wrap to first, * or MAX_NUMNODES - * int first_unset_node(mask) First node not set in mask, or + * unsigned int first_unset_node(mask) First node not set in mask, or * MAX_NUMNODES * * nodemask_t nodemask_of_node(node) Return nodemask with bit 'node' set @@ -153,7 +153,7 @@ static inline void __nodes_clear(nodemask_t *dstp, unsigned int nbits) #define node_test_and_set(node, nodemask) \ __node_test_and_set((node), &(nodemask)) -static inline int __node_test_and_set(int node, nodemask_t *addr) +static inline bool __node_test_and_set(int node, nodemask_t *addr) { return test_and_set_bit(node, addr->bits); } @@ -200,7 +200,7 @@ static inline void __nodes_complement(nodemask_t *dstp, #define nodes_equal(src1, src2) \ __nodes_equal(&(src1), &(src2), MAX_NUMNODES) -static inline int __nodes_equal(const nodemask_t *src1p, +static inline bool __nodes_equal(const nodemask_t *src1p, const nodemask_t *src2p, unsigned int nbits) { return bitmap_equal(src1p->bits, src2p->bits, nbits); @@ -208,7 +208,7 @@ static inline int __nodes_equal(const nodemask_t *src1p, #define nodes_intersects(src1, src2) \ __nodes_intersects(&(src1), &(src2), MAX_NUMNODES) -static inline int __nodes_intersects(const nodemask_t *src1p, +static inline bool __nodes_intersects(const nodemask_t *src1p, const nodemask_t *src2p, unsigned int nbits) { return bitmap_intersects(src1p->bits, src2p->bits, nbits); @@ -216,20 +216,20 @@ static inline int __nodes_intersects(const nodemask_t *src1p, #define nodes_subset(src1, src2) \ __nodes_subset(&(src1), &(src2), MAX_NUMNODES) -static inline int __nodes_subset(const nodemask_t *src1p, +static inline bool __nodes_subset(const nodemask_t *src1p, const nodemask_t *src2p, unsigned int nbits) { return bitmap_subset(src1p->bits, src2p->bits, nbits); } #define nodes_empty(src) __nodes_empty(&(src), MAX_NUMNODES) -static inline int __nodes_empty(const nodemask_t *srcp, unsigned int nbits) +static inline bool __nodes_empty(const nodemask_t *srcp, unsigned int nbits) { return bitmap_empty(srcp->bits, nbits); } #define nodes_full(nodemask) __nodes_full(&(nodemask), MAX_NUMNODES) -static inline int __nodes_full(const nodemask_t *srcp, unsigned int nbits) +static inline bool __nodes_full(const nodemask_t *srcp, unsigned int nbits) { return bitmap_full(srcp->bits, nbits); } @@ -260,15 +260,15 @@ static inline void __nodes_shift_left(nodemask_t *dstp, > MAX_NUMNODES, then the silly min_ts could be dropped. */ #define first_node(src) __first_node(&(src)) -static inline int __first_node(const nodemask_t *srcp) +static inline unsigned int __first_node(const nodemask_t *srcp) { - return min_t(int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES)); + return min_t(unsigned int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES)); } #define next_node(n, src) __next_node((n), &(src)) -static inline int __next_node(int n, const nodemask_t *srcp) +static inline unsigned int __next_node(int n, const nodemask_t *srcp) { - return min_t(int,MAX_NUMNODES,find_next_bit(srcp->bits, MAX_NUMNODES, n+1)); + return min_t(unsigned int, MAX_NUMNODES, find_next_bit(srcp->bits, MAX_NUMNODES, n+1)); } /* @@ -276,7 +276,7 @@ static inline int __next_node(int n, const nodemask_t *srcp) * the first node in src if needed. Returns MAX_NUMNODES if src is empty. */ #define next_node_in(n, src) __next_node_in((n), &(src)) -int __next_node_in(int node, const nodemask_t *srcp); +unsigned int __next_node_in(int node, const nodemask_t *srcp); static inline void init_nodemask_of_node(nodemask_t *mask, int node) { @@ -296,9 +296,9 @@ static inline void init_nodemask_of_node(nodemask_t *mask, int node) }) #define first_unset_node(mask) __first_unset_node(&(mask)) -static inline int __first_unset_node(const nodemask_t *maskp) +static inline unsigned int __first_unset_node(const nodemask_t *maskp) { - return min_t(int,MAX_NUMNODES, + return min_t(unsigned int, MAX_NUMNODES, find_first_zero_bit(maskp->bits, MAX_NUMNODES)); } @@ -436,11 +436,11 @@ static inline int num_node_state(enum node_states state) #define first_online_node first_node(node_states[N_ONLINE]) #define first_memory_node first_node(node_states[N_MEMORY]) -static inline int next_online_node(int nid) +static inline unsigned int next_online_node(int nid) { return next_node(nid, node_states[N_ONLINE]); } -static inline int next_memory_node(int nid) +static inline unsigned int next_memory_node(int nid) { return next_node(nid, node_states[N_MEMORY]); } diff --git a/lib/nodemask.c b/lib/nodemask.c index 3aa454c54c0d..a334cf722189 100644 --- a/lib/nodemask.c +++ b/lib/nodemask.c @@ -3,7 +3,7 @@ #include #include -int __next_node_in(int node, const nodemask_t *srcp) +unsigned int __next_node_in(int node, const nodemask_t *srcp) { int ret = __next_node(node, srcp);