From patchwork Wed Jul 6 17:42:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12908420 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4DEDC433EF for ; Wed, 6 Jul 2022 17:43:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A9626B007B; Wed, 6 Jul 2022 13:43:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7321B6B007D; Wed, 6 Jul 2022 13:43:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AC376B007E; Wed, 6 Jul 2022 13:43:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4541E6B007B for ; Wed, 6 Jul 2022 13:43:03 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2143220D0E for ; Wed, 6 Jul 2022 17:43:03 +0000 (UTC) X-FDA: 79657395846.30.152A4FD Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by imf03.hostedemail.com (Postfix) with ESMTP id 99ADD20016 for ; Wed, 6 Jul 2022 17:43:02 +0000 (UTC) Received: by mail-qk1-f181.google.com with SMTP id o26so4486938qkl.6 for ; Wed, 06 Jul 2022 10:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dALoUA4TxajQrqRALn6VbZI9jeqizcyFDqXo6cANVYg=; b=nyC2+Sd3jhh/LEdWlSwYv/Wi4xBn2p0D6oGj4gyhLtswzAziH455Bo9wgTrHjKchaV CgUOBfvEIp05FREyeEJMqK5TnX3mvRi6YSZnByT/LapbrtBBCTloUMHia4TbdAzGAGGH yY1KGijCX0HOQO/4Fwk0fjkWegstt6IE3XkXQbCLYVn+Fhs3HUBfRuSjlDJWq7bBd1FO MyD9Gvd/RAl4BUcDs/vKsJGcH5CMvMnBRnNZLsbxy5ZsmvDEmVUou6TFYWQuwlwqmDWf XQFta9TFMS1sbaW+k3Fb4Zoa0W/mQbOCznzdToKyxHsXU+B5RB7a6dgcM8Q8VepDZxAo 6lTw== 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=dALoUA4TxajQrqRALn6VbZI9jeqizcyFDqXo6cANVYg=; b=kd27WKgLuiPFAgp+i7/sSAG5A5Br9q9MdgMAK2C5HbAId6dc0llGx2HQlLux5EFW8f JcWG6MZASWs87Y8GXVP3V4QHyOF3n6Kun9FJW+NX6JNNxXZtOeqN6/8sOZYGo0rvbV5K 3vgUPnRKnofAWZMGZxaYl4D0kkPhC85YPZZjeHRTFPR/Gf2iP4U1yI/gR3PyoMYJJuRF vX2Z2gONs2xJ4cXGNSsJKtpgAO/l546dK+7J6yBB8fbhZtJn/sCuTj8MwYH4bZZd5q3z ij4V0si5wqLXsSceb8qHH+KzJFKO2YL+MvWfX7kbMhM6fhANfgaogoAZxzTF9IFVNVRj qfxA== X-Gm-Message-State: AJIora8zVBOtYirxGcjAabJz0YFwKv+uhbBHWN8f9+35AaUAb2BYZiGe 5ku8mI+pTvGWdtpuTuzsYhM= X-Google-Smtp-Source: AGRyM1uJ3hnFVUVKR+5A0tRR91nKmtjdOKPHZTHRMDZPsx7tXoYTXb9HZejmviIagEKCPhwWCBzbHg== X-Received: by 2002:a37:644b:0:b0:6af:3529:2bb8 with SMTP id y72-20020a37644b000000b006af35292bb8mr27450858qkb.341.1657129381738; Wed, 06 Jul 2022 10:43:01 -0700 (PDT) Received: from localhost (c-69-254-185-160.hsd1.fl.comcast.net. [69.254.185.160]) by smtp.gmail.com with ESMTPSA id v38-20020a05622a18a600b0031a84ecd4d1sm20818859qtc.95.2022.07.06.10.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 10:43:01 -0700 (PDT) From: Yury Norov To: linux-kernel@vger.kernel.org, Andrew Morton , Andy Shevchenko , David Howells , Ingo Molnar , Geert Uytterhoeven , Jonathan Corbet , "Kirill A . Shutemov" , Matthew Wilcox , NeilBrown , Rasmus Villemoes , Russell King , Vlastimil Babka , William Kucharski , linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Cc: Yury Norov Subject: [PATCH 05/10] lib/cpumask: change return types to unsigned where appropriate Date: Wed, 6 Jul 2022 10:42:48 -0700 Message-Id: <20220706174253.4175492-6-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220706174253.4175492-1-yury.norov@gmail.com> References: <20220706174253.4175492-1-yury.norov@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657129382; a=rsa-sha256; cv=none; b=CXYTPv0rkdTXq3mkl0aulfDD6SYUOSx5wpgx1uAIEpFAGS4Y5RrjEAe+z/e5hBsvxSktXe Gf/0Jo28kRHpMlnAobkXYqSKja9YkQX8qo8JIoFnWcvtiEU/XzY3JrExkOmetCpXXLQNyh Kdg9XBpp032KVj6qrePbs60lRaGW4LQ= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nyC2+Sd3; spf=pass (imf03.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.222.181 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657129382; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dALoUA4TxajQrqRALn6VbZI9jeqizcyFDqXo6cANVYg=; b=F/qAUwWeOyUMpwmSiESaPVL3CyUQX9ZRhONVFp4KotWeHsThEEIHu4EwT16TccO4EUwn7/ /F+12r0MJzz/CTjsmitwJzVrposzxPkpqaFiCWMhGqBgilMk9M2gZusbjd/NEjH3CHBX1t WaLu3rytw22NyvwWBJVWBkQPBWCLq/g= Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nyC2+Sd3; spf=pass (imf03.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.222.181 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: gxnskwuhgp33xduki5frko3fensw7ku6 X-Rspamd-Queue-Id: 99ADD20016 X-HE-Tag: 1657129382-102373 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Switch return types to unsigned int where return values cannot be negative. Signed-off-by: Yury Norov --- include/linux/cpumask.h | 14 +++++++------- lib/cpumask.c | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index b54e27d9da6b..760022bcb925 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -176,12 +176,12 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node) return 0; } -static inline int cpumask_any_and_distribute(const struct cpumask *src1p, +static inline unsigned int cpumask_any_and_distribute(const struct cpumask *src1p, const struct cpumask *src2p) { return cpumask_first_and(src1p, src2p); } -static inline int cpumask_any_distribute(const struct cpumask *srcp) +static inline unsigned int cpumask_any_distribute(const struct cpumask *srcp) { return cpumask_first(srcp); } @@ -258,12 +258,12 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp) return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1); } -int __pure cpumask_next_and(int n, const struct cpumask *, const struct cpumask *); -int __pure cpumask_any_but(const struct cpumask *mask, unsigned int cpu); +unsigned int __pure cpumask_next_and(int n, const struct cpumask *, const struct cpumask *); +unsigned int __pure cpumask_any_but(const struct cpumask *mask, unsigned int cpu); unsigned int cpumask_local_spread(unsigned int i, int node); -int cpumask_any_and_distribute(const struct cpumask *src1p, +unsigned int cpumask_any_and_distribute(const struct cpumask *src1p, const struct cpumask *src2p); -int cpumask_any_distribute(const struct cpumask *srcp); +unsigned int cpumask_any_distribute(const struct cpumask *srcp); /** * for_each_cpu - iterate over every cpu in a mask @@ -289,7 +289,7 @@ int cpumask_any_distribute(const struct cpumask *srcp); (cpu) = cpumask_next_zero((cpu), (mask)), \ (cpu) < nr_cpu_ids;) -extern int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap); +unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap); /** * for_each_cpu_wrap - iterate over every cpu in a mask, starting at a specified location diff --git a/lib/cpumask.c b/lib/cpumask.c index a971a82d2f43..da68f6bbde44 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -31,7 +31,7 @@ EXPORT_SYMBOL(cpumask_next); * * Returns >= nr_cpu_ids if no further cpus set in both. */ -int cpumask_next_and(int n, const struct cpumask *src1p, +unsigned int cpumask_next_and(int n, const struct cpumask *src1p, const struct cpumask *src2p) { /* -1 is a legal arg here. */ @@ -50,7 +50,7 @@ EXPORT_SYMBOL(cpumask_next_and); * Often used to find any cpu but smp_processor_id() in a mask. * Returns >= nr_cpu_ids if no cpus set. */ -int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) +unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) { unsigned int i; @@ -74,9 +74,9 @@ EXPORT_SYMBOL(cpumask_any_but); * Note: the @wrap argument is required for the start condition when * we cannot assume @start is set in @mask. */ -int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap) +unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap) { - int next; + unsigned int next; again: next = cpumask_next(n, mask); @@ -205,7 +205,7 @@ void __init free_bootmem_cpumask_var(cpumask_var_t mask) */ unsigned int cpumask_local_spread(unsigned int i, int node) { - int cpu; + unsigned int cpu; /* Wrap: we always want a cpu. */ i %= num_online_cpus(); @@ -243,10 +243,10 @@ static DEFINE_PER_CPU(int, distribute_cpu_mask_prev); * * Returns >= nr_cpu_ids if the intersection is empty. */ -int cpumask_any_and_distribute(const struct cpumask *src1p, +unsigned int cpumask_any_and_distribute(const struct cpumask *src1p, const struct cpumask *src2p) { - int next, prev; + unsigned int next, prev; /* NOTE: our first selection will skip 0. */ prev = __this_cpu_read(distribute_cpu_mask_prev); @@ -262,9 +262,9 @@ int cpumask_any_and_distribute(const struct cpumask *src1p, } EXPORT_SYMBOL(cpumask_any_and_distribute); -int cpumask_any_distribute(const struct cpumask *srcp) +unsigned int cpumask_any_distribute(const struct cpumask *srcp) { - int next, prev; + unsigned int next, prev; /* NOTE: our first selection will skip 0. */ prev = __this_cpu_read(distribute_cpu_mask_prev);