2021-10-13 07:41:45

by 王擎

[permalink] [raw]
Subject: 回复: [PATCH] bcache: replace snprintf in s how functions with sysfs_emit


>>
>> diff --git a/drivers/md/bcache/sysfs.h b/drivers/md/bcache/sysfs.h
>> index 215df32..8bec32d 100644
>> --- a/drivers/md/bcache/sysfs.h
>> +++ b/drivers/md/bcache/sysfs.h
>> @@ -51,7 +51,7 @@ STORE(fn)                                                           \
>>   #define sysfs_printf(file, fmt, ...)                                        \
>>   do {                                                                        \
>>        if (attr == &sysfs_ ## file)                                    \
>> -             return snprintf(buf, PAGE_SIZE, fmt "\n", __VA_ARGS__); \
>> +             return sysfs_emit(buf, fmt "\n", __VA_ARGS__);  \
>>   } while (0)
>>  
>>   #define sysfs_print(file, var)                                              \
>
> IMHO I like this change :-) BTW, for snprint() from util.h, it seems
> only to be used by sysfs_print() in syfs.h, would you like to change it
> to use sysfs_emit too ?
>
> Thanks for the patch.
>
> Coly Li
>

sysfs_print() should also be modified if size is a fixed value PAGE_SIZE,
but here is param, it would be appreciate if you have better method.

Thanks,

Qing


2021-10-13 07:53:50

by Coly Li

[permalink] [raw]
Subject: Re: 回复: [PATCH] bcache: replace snprin tf in show functions with sysfs_emit

On 10/13/21 3:39 PM, 王擎 wrote:
>>> diff --git a/drivers/md/bcache/sysfs.h b/drivers/md/bcache/sysfs.h
>>> index 215df32..8bec32d 100644
>>> --- a/drivers/md/bcache/sysfs.h
>>> +++ b/drivers/md/bcache/sysfs.h
>>> @@ -51,7 +51,7 @@ STORE(fn)                                                           \
>>>    #define sysfs_printf(file, fmt, ...)                                        \
>>>    do {                                                                        \
>>>         if (attr == &sysfs_ ## file)                                    \
>>> -             return snprintf(buf, PAGE_SIZE, fmt "\n", __VA_ARGS__); \
>>> +             return sysfs_emit(buf, fmt "\n", __VA_ARGS__);  \
>>>    } while (0)
>>>
>>>    #define sysfs_print(file, var)                                              \
>> IMHO I like this change :-) BTW, for snprint() from util.h, it seems
>> only to be used by sysfs_print() in syfs.h, would you like to change it
>> to use sysfs_emit too ?
>>
>> Thanks for the patch.
>>
>> Coly Li
>>
> sysfs_print() should also be modified if size is a fixed value PAGE_SIZE,
> but here is param, it would be appreciate if you have better method.

Yes, I meant you may implement sysfs_print() by sysfs_emit() directly in
the way as snprint() does. Then you may remove snprint() since no one
uses it any more.

Coly Li