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

Andrew Lunn andrew at lunn.ch
Tue Nov 29 10:25:41 PST 2022


On Tue, Nov 29, 2022 at 03:02:28PM +0800, yang.yang29 at zte.com.cn wrote:
> From: Xu Panda <xu.panda at zte.com.cn>
> 
> 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



More information about the linux-arm-kernel mailing list