[lvc-project] [PATCH net-next] stmmac: dwmac-intel-plat: remove redundant check dwmac->data in probe

Andrew Lunn andrew at lunn.ch
Mon Sep 30 22:17:45 MSK 2024


On Mon, Sep 30, 2024 at 09:39:26PM +0300, Vitalii Mordan wrote:
> The driver’s compatibility with devices is confirmed earlier in
> platform_match(). Since reaching probe means the device is valid,
> the extra check can be removed to simplify the code.
>  
>  	dwmac->data = device_get_match_data(&pdev->dev);
> -	if (dwmac->data) {

You say this cannot fail, but my guess is, there are static code
analysers which cannot determine it cannot fail. As a result, those
developers blindly following bots are going to want to test the return
value from device_get_match_data().

You might want to prevent such patches by adding a comment:

/* This cannot fail because....

   Andrew



More information about the lvc-project mailing list