lkml.org 
[lkml]   [2022]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 3/7] s390/qeth: Convert snprintf() to scnprintf()
From


On 27.09.22 16:27, Joe Perches wrote:
> On Mon, 2022-09-26 at 19:42 +0100, Jules Irenge wrote:
>> Coccinnelle reports a warning
>> Warning: Use scnprintf or sprintf
>> Adding to that, there has been a slow migration from snprintf to scnprintf.
>> This LWN article explains the rationale for this change
>> https: //lwn.net/Articles/69419/
>> Ie. snprintf() returns what *would* be the resulting length,
>> while scnprintf() returns the actual length.
> []
>> diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c
> []
>> @@ -500,9 +500,9 @@ static ssize_t qeth_hw_trap_show(struct device *dev,
>> struct qeth_card *card = dev_get_drvdata(dev);
>>
>> if (card->info.hwtrap)
>> - return snprintf(buf, 5, "arm\n");
>> + return scnprintf(buf, 5, "arm\n");
>> else
>> - return snprintf(buf, 8, "disarm\n");
>> + return scnprintf(buf, 8, "disarm\n");
>> }
>
> Use sysfs_emit instead.
>

Thank you Joe, that sounds like the best way to handle this.
I propose that I take this onto my ToDo list and test it in the s390 environment.
I will add
Reported-by: Jules Irenge <jbi.octave@gmail.com>
Suggested-by: Joe Perches <joe@perches.com>

\
 
 \ /
  Last update: 2022-09-28 10:26    [W:0.057 / U:0.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site