Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2030963rdd; Thu, 11 Jan 2024 18:08:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpZRpdlqsTrOEnz/bkqnuKj9MGx22XPl+6mpRTjMEEXUNZcI4domEh+mB12jCswPOPXfbU X-Received: by 2002:a05:622a:193:b0:429:caa8:53bf with SMTP id s19-20020a05622a019300b00429caa853bfmr1197757qtw.7.1705025309901; Thu, 11 Jan 2024 18:08:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705025309; cv=none; d=google.com; s=arc-20160816; b=i42Vt3ztJosFjzK77quE+6VOSspXocakDEfBg26EK8ih1afTPK82Wvch0xBti4KIl6 01c4m8yKChSlg3Bml0unT3nnQAPvCb+7VrFaj83o39VhwMbPAmHYEsNa0jkxT05/12tL 6v8JYZ1WIyHS/WYpKqe3TZpIdozzmnIyKatfuJH3+TAGKlocPUZjqq9SH3+GrNpGxmXA iaKFY0Svsa/pAMvLHIuublv9G0LaZYsVzevsmRnbAVWulsAUs04kIIui3vr78VVV0RNh lCETZJGX+nAf7dYyl2VGWA6vmVUGneR3tXpvjtHLPCSTUCCzNmfAGzm1VaODbHU/D/uf 3FYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=Av/eq/nWgYze9DHw/whtba1h6eCvgLh2s3Om4RasXGw=; fh=/YeIsC882I45dlqGUcm20dvbkohg5JzeYrfHTaftsWM=; b=ZAIUtQFeZD/L+ZSmsHcxewq88YggnbVZOwa+80BnVkSSjqNekFo7yZ1RztWbTNCfgO Bq8ZZkkCtgXUVsurej75ycaaxONkpEnJvy3V+Ngt5EW7Mvp4qUA8upVnMoIVIhvph8Qk ribghOsSOiiTUSKUnWIW6hbDSThxjspX+rjuosXhCI+Al3gxIla88JiG6yYh7+Leen3H c1g2FSNqonn30WfyglX+Cg3JgcW58xBO/KGUKIDPGij1q6dyrBZzWCHIxV3jUD2F1Om0 8tnl5Tob6W77W/Y+gJuMnf4q3C+znN8hXh86qVqQD/MuWHfUODAMxycfM7iC4WBZpBRp BAyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i10-20020ac85c0a000000b00429a6f45c2esi2171970qti.598.2024.01.11.18.08.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 18:08:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A8FE71C22CC1 for ; Fri, 12 Jan 2024 02:08:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8E77111A; Fri, 12 Jan 2024 02:08:23 +0000 (UTC) Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59E17ED7 for ; Fri, 12 Jan 2024 02:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0W-R94xv_1705024971; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0W-R94xv_1705024971) by smtp.aliyun-inc.com; Fri, 12 Jan 2024 10:03:00 +0800 From: Jiapeng Chong To: tglx@linutronix.de Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH] lib/group_cpus: Fix unsigned expression compared with zero Date: Fri, 12 Jan 2024 10:02:50 +0800 Message-Id: <20240112020250.48087-1-jiapeng.chong@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The nr_present and nr_others is defined as unsigned int type, if(nr_present < 0) and if(nr_others < 0 )is invalid. At the same time, the return value of function __group_cpus_evenly also of type int. so modified the types of nr_present and nr_others to int. lib/group_cpus.c:380 group_cpus_evenly() warn: unsigned 'nr_present' is never less than zero. lib/group_cpus.c:396 group_cpus_evenly() warn: unsigned 'nr_others' is never less than zero. Reported-by: Abaci Robot Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7890 Signed-off-by: Jiapeng Chong --- lib/group_cpus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/group_cpus.c b/lib/group_cpus.c index 3a0db0f51f09..08e31f2f053f 100644 --- a/lib/group_cpus.c +++ b/lib/group_cpus.c @@ -354,7 +354,8 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps) cpumask_var_t *node_to_cpumask __free(free_node_to_cpumask) = alloc_node_to_cpumask(); struct cpumask *masks __free(kfree) = kcalloc(numgrps, sizeof(*masks), GFP_KERNEL); cpumask_var_t npresmsk __free(free_cpumask_var); - unsigned int curgrp, nr_present, nr_others; + unsigned int curgrp; + int nr_present, nr_others; if (!masks || !node_to_cpumask || !alloc_cpumask_var(&npresmsk, GFP_KERNEL)) return NULL; -- 2.20.1.7.g153144c