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] [day] [month] [year] [list]
Message-Id: <0DC3481B-747E-4874-BDD5-47016A0C4916@suse.de>
Date:   Wed, 7 Dec 2022 21:04:50 +0800
From:   Coly Li <colyli@...e.de>
To:     ye.xingchen@....com.cn
Cc:     Kent Overstreet <kent.overstreet@...il.com>,
        linux-bcache@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bcache: Convert to use sysfs_emit()/sysfs_emit_at() APIs



> 2022年12月7日 17:02,<ye.xingchen@....com.cn> <ye.xingchen@....com.cn> 写道:
> 
> 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>

Added to my for-next queue for Linux v6.3 merge window.

Thanks.

Coly Li


> ---
> drivers/md/bcache/sysfs.c | 31 +++++++++++++++----------------
> 1 file changed, 15 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
> index c6f677059214..0e2c1880f60b 100644
> --- a/drivers/md/bcache/sysfs.c
> +++ b/drivers/md/bcache/sysfs.c
> @@ -1111,26 +1111,25 @@ SHOW(__bch_cache)
> 
> vfree(p);
> 
> - ret = scnprintf(buf, PAGE_SIZE,
> - "Unused: %zu%%\n"
> - "Clean: %zu%%\n"
> - "Dirty: %zu%%\n"
> - "Metadata: %zu%%\n"
> - "Average: %llu\n"
> - "Sectors per Q: %zu\n"
> - "Quantiles: [",
> - unused * 100 / (size_t) ca->sb.nbuckets,
> - available * 100 / (size_t) ca->sb.nbuckets,
> - dirty * 100 / (size_t) ca->sb.nbuckets,
> - meta * 100 / (size_t) ca->sb.nbuckets, sum,
> - n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1));
> + ret = sysfs_emit(buf,
> + "Unused: %zu%%\n"
> + "Clean: %zu%%\n"
> + "Dirty: %zu%%\n"
> + "Metadata: %zu%%\n"
> + "Average: %llu\n"
> + "Sectors per Q: %zu\n"
> + "Quantiles: [",
> + unused * 100 / (size_t) ca->sb.nbuckets,
> + available * 100 / (size_t) ca->sb.nbuckets,
> + dirty * 100 / (size_t) ca->sb.nbuckets,
> + meta * 100 / (size_t) ca->sb.nbuckets, sum,
> + n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1));
> 
> for (i = 0; i < ARRAY_SIZE(q); i++)
> - ret += scnprintf(buf + ret, PAGE_SIZE - ret,
> - "%u ", q[i]);
> + ret += sysfs_emit_at(buf, ret, "%u ", q[i]);
> ret--;
> 
> - ret += scnprintf(buf + ret, PAGE_SIZE - ret, "]\n");
> + ret += sysfs_emit_at(buf, ret, "]\n");
> 
> return ret;
> }
> -- 
> 2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ