Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2271615pxb; Thu, 28 Oct 2021 20:37:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys422b/QEo/+hbO/2H+sAXJPkD7BpLZFDB8kB7aTIHmfXZ0Rssx66Q26eFcOmcpFrM+MuC X-Received: by 2002:a17:90a:e7cc:: with SMTP id kb12mr8857460pjb.176.1635478629263; Thu, 28 Oct 2021 20:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635478629; cv=none; d=google.com; s=arc-20160816; b=vuw4UWMQVheAEHkfynA/i0nTg2Jbd5UXi8vfqDL/mhfgCg9nmcLWcStm9+rJuOiLfJ fwDNTEOoZcT86K34FflcuTmzFzFLq7m1+LztvzTvUFMIe0rG3xKd1MbZBWorndSte0g4 3oxv7fZlTvJywQstbM9Y19HB6KCYOB7ZRwjk+ghH2//xqAYqz0TrTqlgjXKWs+NhXoQ0 py+hJlKWKUKAa9iMGUZ+LCAP15+7RTIh/rDl7yLfZ5+3yC5h1rmLwRSdMRH/Q/DurV2P eAhLYSAXadmCh4iXoFivveLOtL8ZSXdwue7sef3G/zy+yJB+7AsyS/9+JjirUtXvSCMQ KCTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=0ar0s/t0y2XXAYR0GxmKXDwSZtuaYjaIzhI1Wg9iRWQ=; b=DX0a4rFqTNnwWXejJ25WL3VVRUWrDyrDn3GpNFgH1Uwr+NB015nyd0bz+pJAa47EqK Uiau5t1EG1dLkVxAO91G3O8ugOkkRxruElvWy90movpkk68Cjf84rJPoT5sK09mrhHlK dTjGaumZvlNrc+o/sozEPBJ9HcIv80mloJB9dh15eKAuAhu3yPn2XdU5VQ5ZeiCEshN6 I/4efTrZirAJlG1MeEyPkcB20G+3d9VvEw12F1AiTCqpek2XX43Gn5ETnswLnRS1dtSk waS16QGRkXOMepc+t2bIDs62sn/zC+Ybiuw+mgPKzJcKpPJWuzorEBC+CyHiQMKOY8C+ iONQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si8608583pfg.150.2021.10.28.20.36.56; Thu, 28 Oct 2021 20:37:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231665AbhJ2Dia (ORCPT + 99 others); Thu, 28 Oct 2021 23:38:30 -0400 Received: from smtp25.cstnet.cn ([159.226.251.25]:37582 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231611AbhJ2Di3 (ORCPT ); Thu, 28 Oct 2021 23:38:29 -0400 Received: from localhost.localdomain (unknown [124.16.138.128]) by APP-05 (Coremail) with SMTP id zQCowAAH6e32a3thTamVBQ--.42489S2; Fri, 29 Oct 2021 11:35:18 +0800 (CST) From: Jiasheng Jiang To: rjw@rjwysocki.net, viresh.kumar@linaro.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] cpufreq: Fix implicit type conversion Date: Fri, 29 Oct 2021 03:35:17 +0000 Message-Id: <1635478517-3071352-1-git-send-email-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANS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DU0xZFpf9x0JUk3ktUUUUU= X-Originating-IP: [124.16.138.128] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The variable 'cpu' and 'j' are defined as unsigned int. However in the for_each_cpu, their values are assigned to -1. That doesn't make sense and in the cpumask_next() they are implicitly type conversed to int. It is universally accepted that the implicit type conversion is terrible. Also, having the good programming custom will set an example for others. Thus, it might be better to change the definition of 'cpu' and 'j' from unsigned int to int. Signed-off-by: Jiasheng Jiang --- kernel/sched/cpufreq_schedutil.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 4f09afd..4aff4b6 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -409,7 +409,7 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time) struct sugov_policy *sg_policy = sg_cpu->sg_policy; struct cpufreq_policy *policy = sg_policy->policy; unsigned long util = 0, max = 1; - unsigned int j; + int j; for_each_cpu(j, policy->cpus) { struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j); @@ -746,7 +746,7 @@ static int sugov_start(struct cpufreq_policy *policy) { struct sugov_policy *sg_policy = policy->governor_data; void (*uu)(struct update_util_data *data, u64 time, unsigned int flags); - unsigned int cpu; + int cpu; sg_policy->freq_update_delay_ns = sg_policy->tunables->rate_limit_us * NSEC_PER_USEC; sg_policy->last_freq_update_time = 0; @@ -783,7 +783,7 @@ static int sugov_start(struct cpufreq_policy *policy) static void sugov_stop(struct cpufreq_policy *policy) { struct sugov_policy *sg_policy = policy->governor_data; - unsigned int cpu; + int cpu; for_each_cpu(cpu, policy->cpus) cpufreq_remove_update_util_hook(cpu); -- 2.7.4