Re: [PATCH] xfs: replace snprintf in show functions with sysfs_emit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2021-10-12 at 20:29 -0700, Qing Wang wrote:
> coccicheck complains about the use of snprintf() in sysfs show functions.
> 
> Fix the coccicheck warning:
> WARNING: use scnprintf or sprintf.
> 
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
[]
> diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
[]
> @@ -104,7 +104,7 @@ bug_on_assert_show(
>  	struct kobject		*kobject,
>  	char			*buf)
>  {
> -	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bug_on_assert ? 1 : 0);
> +	return sysfs_emit(buf, "%d\n", xfs_globals.bug_on_assert ? 1 : 0);

trivia:

The ?: is not necessary as xfs_globals.bug_on_assert is a bool
and would have an implicit cast done.

	return sysfs_emit(buf, "%d\n", xfs_globals.bug_on_assert);





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux