brcm80211: Drop unnecessary NULL check after container_of
PATCH 1/1 brcm80211: Drop unnecessary NULL check after container_of
The parameter passed to ai_detach() is guaranteed to never be NULL because it is checked by the caller. Consequently, the result of container_of() on it is also never NULL, and a NULL check on it is unnecessary. Even without that, the NULL check would still be unnecessary because the subsequent kfree() can handle NULL arguments. On top of all that, it is misleading to check the result of container_of() against NULL because the position of the contained element could change, which would make the check invalid. Remove it.
This change was made automatically with the following Coccinelle script.
@@
type t;
identifier v;
statement s;
@@
<+...
(
t v = container_of(...);
|
v = container_of(...);
)
...
when != v
- if (\( !v \| v == NULL \) ) s
...+>
--- drivers/net/wireless/broadcom/brcm80211/brcmsmac/aiutils.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/aiutils.c +0 -3
@@ -531,9 +531,6 @@ void ai_detach(struct si_pub *sih) sii = container_of(sih, struct si_info, pub); -if (sii ==NULL ) -return ; -kfree (sii); }
Signature · 1 line
2.25.1
Re: brcmsmac: Drop unnecessary NULL check after container_of
Quoted 28 lines · Guenter Roeck
The parameter passed to
ai_detach()is guaranteed to never be NULL because it is checked by the caller. Consequently, the result ofcontainer_of()on it is also never NULL, and a NULL check on it is unnecessary. Even without that, the NULL check would still be unnecessary because the subsequentkfree()can handle NULL arguments. On top of all that, it is misleading to check the result ofcontainer_of()against NULL because the position of the contained element could change, which would make the check invalid. Remove it.This change was made automatically with the following Coccinelle script.
@@
type t;
identifier v;
statement s;
@@<+...
(
t v =container_of(...);
|
v =container_of(...);
)
...
when != v
- if (\( !v \| v == NULL \) ) s
...+>
Quoted 1 line
Signed-off-by Guenter Roeck <[email protected]>
Patch applied to wireless-drivers-next.git, thanks.
34fe7038a3b3 brcmsmac: Drop unnecessary NULL check after container_of
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches