lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221206084558.kv7y4mmkuccrojgg@vireshk-i7>
Date:   Tue, 6 Dec 2022 14:15:58 +0530
From:   Viresh Kumar <viresh.kumar@...aro.org>
To:     ye.xingchen@....com.cn
Cc:     rafael@...nel.org, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cpufreq: stats: Convert to use sysfs_emit_at() API

On 06-12-22, 16:15, ye.xingchen@....com.cn wrote:
> From: ye xingchen <ye.xingchen@....com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: ye xingchen <ye.xingchen@....com.cn>
> ---
>  drivers/cpufreq/cpufreq_stats.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
> index 1570d6f3e75d..55c7ffd37d1c 100644
> --- a/drivers/cpufreq/cpufreq_stats.c
> +++ b/drivers/cpufreq/cpufreq_stats.c
> @@ -128,25 +128,23 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
>  	ssize_t len = 0;
>  	int i, j, count;
> 
> -	len += scnprintf(buf + len, PAGE_SIZE - len, "   From  :    To\n");
> -	len += scnprintf(buf + len, PAGE_SIZE - len, "         : ");
> +	len += sysfs_emit_at(buf, len, "   From  :    To\n");
> +	len += sysfs_emit_at(buf, len, "         : ");
>  	for (i = 0; i < stats->state_num; i++) {
>  		if (len >= PAGE_SIZE)
>  			break;
> -		len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ",
> -				stats->freq_table[i]);
> +		len += sysfs_emit_at(buf, len, "%9u ", stats->freq_table[i]);
>  	}
>  	if (len >= PAGE_SIZE)
>  		return PAGE_SIZE;
> 
> -	len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
> +	len += sysfs_emit_at(buf, len, "\n");
> 
>  	for (i = 0; i < stats->state_num; i++) {
>  		if (len >= PAGE_SIZE)
>  			break;
> 
> -		len += scnprintf(buf + len, PAGE_SIZE - len, "%9u: ",
> -				stats->freq_table[i]);
> +		len += sysfs_emit_at(buf, len, "%9u: ", stats->freq_table[i]);
> 
>  		for (j = 0; j < stats->state_num; j++) {
>  			if (len >= PAGE_SIZE)
> @@ -157,11 +155,11 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
>  			else
>  				count = stats->trans_table[i * stats->max_state + j];
> 
> -			len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ", count);
> +			len += sysfs_emit_at(buf, len, "%9u ", count);
>  		}
>  		if (len >= PAGE_SIZE)
>  			break;
> -		len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
> +		len += sysfs_emit_at(buf, len, "\n");
>  	}
> 
>  	if (len >= PAGE_SIZE) {

Acked-by: Viresh Kumar <viresh.kumar@...aro.org>

-- 
viresh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ