Re: [PATCH] x86: event, use scnprintf instead of snprintf

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

 



On Thu, Jan 09, 2020 at 02:36:26PM +0800, liuyang34 wrote:
> the return size will low than PAGE_SIZE but maybe over 40 in show_sysctl_tfa,
> so use scnprintf instead of snprintf to get real size
> 
> Signed-off-by: liuyang34 <liuyang34@xxxxxxxxxx>
> ---
>  arch/x86/events/intel/core.c    | 6 +++---
>  arch/x86/events/intel/pt.c      | 2 +-
>  arch/x86/platform/uv/uv_sysfs.c | 4 ++--
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
> index 3be51aa..bf287b4 100644
> --- a/arch/x86/events/intel/core.c
> +++ b/arch/x86/events/intel/core.c
> @@ -4372,7 +4372,7 @@ static ssize_t show_sysctl_tfa(struct device *cdev,
>  			      struct device_attribute *attr,
>  			      char *buf)
>  {
> -	return snprintf(buf, 40, "%d\n", allow_tsx_force_abort);
> +	return scnprintf(buf, 40, "%d\n", allow_tsx_force_abort);

No, just use sprintf() for all of these.  We "know" the buffer size is
big enough for a single number.  There's no need for fancy checks for
any sysfs file.

thanks,

greg k-h



[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux