Re: [PATCH linux-next v2] net: stmmac: use sysfs_streq() instead of strncmp()

From: Andrew Lunn
Date: Tue Nov 29 2022 - 13:26:42 EST


On Tue, Nov 29, 2022 at 03:02:28PM +0800, yang.yang29@xxxxxxxxxx wrote:
> From: Xu Panda <xu.panda@xxxxxxxxxx>
>
> Replace the open-code with sysfs_streq().
>
> ---
> change for v2
> - fix the mistake of redundant parameter.

> - } else if (!strncmp(opt, "tc:", 3)) {
> + } else if (sysfs_streq(opt, "tc:")) {
> if (kstrtoint(opt + 3, 0, &tc))
> goto err;

Vladimir made the comment:

> What's even worse is that the patch is flat out wrong. The stmmac_cmdline_opt()
> function does not parse sysfs input, but cmdline input such as
> "stmmaceth=tc:1,pause:1". The pattern of using strsep() followed by
> strncmp() for such strings is not unique to stmmac, it can also be found
> mainly in drivers under drivers/video/fbdev/.
>
> With strncmp("tc:", 3), the code matches on the "tc:1" token properly.
> With sysfs_streq("tc:"), it doesn't.

It is not clear you have addressed this point.

Andrew