Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2034991rdd; Thu, 11 Jan 2024 18:19:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6AdQTTXIXgUXd6JBS8AryFYkDcnLJMI3Pr3gH3WEfU0VqxS1H6OsSCOgAs7t3lZoOF7R+ X-Received: by 2002:a05:622a:1355:b0:429:bc67:9a7d with SMTP id w21-20020a05622a135500b00429bc679a7dmr2755786qtk.55.1705025980800; Thu, 11 Jan 2024 18:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705025980; cv=none; d=google.com; s=arc-20160816; b=RgVgKsAvLmXHAzb8mzd3bSfPNEOA0aHmw/0M5halM9kf0VMmDglVZXcUlnh1VU5+wK tlLKoFzgulBtUTtn4G4wwvfFsZ5xwPxgUfj97g6Dh/yDNQlgJjGAIyQWuskhKeYwFrf5 0MiGPI0MNtizHai1eW5aERY8nYT0AeZlBnZliJzjNK/LjwlrBMaAeyOjVWBzJNWwwneu SF1kf7e0qlcZxdtrxpVE84cmsp9SDiZ5/Gi15YjMnykT6ESJ1bV5n3+Y4hDh3pqp60N/ +vz5mNOfyT8+ai+048wdYh4eVYiNsdWQxwIp2/Reg6DkFQpWfrXhh3fo/k5alSkba8yG 0Lsw== 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:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=2G6f7drChRRN2Zsh7dX0DuV8eBNDOqhIpdBWU8qvmec=; fh=iuCX7Dl5KmHWABS0QC7l9jTaY0/Li24LfEfhjkapzEU=; b=Le7qpsN6hF+GUBDmAP5v4WxklvoqRmH3NWTFrd3klq311O6zqV8W1omrgNOFu7clH2 svREIV8nbdyYg1aD4GCHgBM9m0g5himBi/X6NykdMVG54jPdq9lxn0o3cfVJKvbvZlHf kDtHZ9sDOxmjglxPUGJD5BGlvespRl6+D0+BCaYFSNHgCyng1CfsmQ2A5P5/QqBrlksc aNL735w/w0yUYbncrigpiGLg8wSJTjYSSXOGOe9iGoyg0S1Vl0CiUclidBxJNMMkFIUq BNLo2x2NCIMstSAkHw1XWhgDt9h+mKR4nG3GLOq6GuNcst9B7w+06TOA7VfV+G4dwAf/ d6ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=wveAHh6j; spf=pass (google.com: domain of linux-kernel+bounces-24227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24227-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t8-20020a05622a148800b0042974d56ad5si2080110qtx.762.2024.01.11.18.19.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 18:19:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=wveAHh6j; spf=pass (google.com: domain of linux-kernel+bounces-24227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24227-linux.lists.archive=gmail.com@vger.kernel.org" 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 910D31C23E03 for ; Fri, 12 Jan 2024 02:19:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97F491399; Fri, 12 Jan 2024 02:19:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="wveAHh6j" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9F5B71117 for ; Fri, 12 Jan 2024 02:19:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AA84C433F1; Fri, 12 Jan 2024 02:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1705025972; bh=jGLKt7eYqBhg4JlNz4xdgTnf3tS7DbNcjW1RCNfMbFQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=wveAHh6jSvZ2H7ZAUXG/TX2KtT+RWzpCFhCAOOotg5D6EnopwMgxXjONsvuD9hnfC HPec7SW2A0nojHl8Fd+vCTg4On8IzUJ/QXzYaUH8JA+CZsiNIJCeGRPIa2OM+QrHGF aKmogL1p7E4J8f2mbW9kxlvI9N6j8LsGoWvvlljw= Date: Thu, 11 Jan 2024 18:19:31 -0800 From: Andrew Morton To: Jiapeng Chong Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, Abaci Robot Subject: Re: [PATCH] lib/group_cpus: Fix unsigned expression compared with zero Message-Id: <20240111181931.e3305d8b55858147e788a190@linux-foundation.org> In-Reply-To: <20240112020250.48087-1-jiapeng.chong@linux.alibaba.com> References: <20240112020250.48087-1-jiapeng.chong@linux.alibaba.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 12 Jan 2024 10:02:50 +0800 Jiapeng Chong wrote: > 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. > > ... > > --- 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; Thanks. Current mm.git (pushed 3 hours ago) has int curgrp, nr_present, nr_others;