]> git.baikalelectronics.ru Git - kernel.git/commit
brcmsmac: Drop unnecessary NULL check after container_of
authorGuenter Roeck <linux@roeck-us.net>
Tue, 11 May 2021 23:56:29 +0000 (16:56 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 15 Jun 2021 10:42:30 +0000 (13:42 +0300)
commit6591c4c1b987e9e6e18e469a9eea9a6270c54e83
tree896cfe678a9cb1c5b6673e35d1cc70be78c74c32
parent53517a698649076819ac6f770b260e4698b3f0a4
brcmsmac: 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
...+>

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210511235629.1686038-1-linux@roeck-us.net
drivers/net/wireless/broadcom/brcm80211/brcmsmac/aiutils.c