Re: [PATCH] mtd: core: Convert sysfs sprintf/snprintf family to sysfs_emit

tiantao (H)
2021-04-12T08:18:30Z

在 2021/4/12 16:07, Richard Weinberger 写道:
> ----- Ursprüngliche Mail -----
>>>> Fix the following coccicheck warning:
>>>> drivers/mtd/mtdcore.c:296:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:306:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:237:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:275:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:286:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:264:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:227:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:162:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:143:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:218:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:208:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:199:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:190:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:152:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:181:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:134:8-16: WARNING: use scnprintf or sprintf
>>>> drivers/mtd/mtdcore.c:171:8-16: WARNING: use scnprintf or sprintf
>>> see: [
>>> https://lore.kernel.org/linux-mtd/CAFLxGvxC4KtvtU2rza_aGx2RPONxr7XygUwXCDriYiCr8qN3qg@mail.gmail.com/
>>> |
>>> https://lore.kernel.org/linux-mtd/CAFLxGvxC4KtvtU2rza_aGx2RPONxr7XygUwXCDriYiCr8qN3qg@mail.gmail.com/
>>> ] Please explain why a patch is needed and what it fixes.
>> Using syfs_emit will avoid buffer overrun by avoiding buf being null or buf
>> being in the middle of the page.
>> no function change.
> All this needs to go into the commit message.
> Like I said, please explain changes.
>
> The coccicheck warning in the commit message is also close to useless because
> it advises you to use scnprintf or sprintf, which is not what your patch does.

understand.

What do you think of the following commit message

Use sysfs_emit instead of snprintf to avoid buf overrun,because in
sysfs_emit it strictly checks

whether buf is null or buf whether pagesize aligned, otherwise it
returns an error.

>
> Thanks,
> //richard
> .