Re: [PATCH] alpha: move from strlcpy with unused retval to strscpy

From: Wolfram Sang
Date: Fri Aug 19 2022 - 01:38:10 EST


Hi Joe,

Glad you like this series.

> Last time I posted a coccinelle script for strlcpy->strscpy conversions
> with unused returns, there were several variants that were not converted.
>
> https://lore.kernel.org/cocci/a3279a5772b2e49b57890cd75e97360b82890798.camel@xxxxxxxxxxx/T/#m502108bfe0cc6a41d499a4c1b55d5f5db1423465
>
> Did you post the script you used?

First version here, very similar to yours:

https://lore.kernel.org/all/YvhXzarjOLEJ8nsW@shikoro/

The final version has another rule to add missing parens to the argument
of a sizeof operator:

@ main @
@@
- strlcpy
+ strscpy
(...);

// make sure sizeof always has parens. Isomorphs will remove existing ones if present before.
@ add_parens depends on main @
expression dst, src, E;
@@
strscpy(dst, src,
- sizeof(E)
+ sizeof(E)
);

Like your try, some header files are missing. I guess Julia's remarks
about that from the thread above will fix this as well. However, since
there are the instances left where the return value of strlcpy is used
anyhow, I left those for manual fixing.

Thanks,

Wolfram

Attachment: signature.asc
Description: PGP signature