netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@codeaurora.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Arend van Spriel <aspriel@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	linux-wireless@vger.kernel.org,
	brcm80211-dev-list.pdl@broadcom.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>
Subject: Re: brcmsmac: Drop unnecessary NULL check after container_of
Date: Tue, 15 Jun 2021 10:42:40 +0000 (UTC)	[thread overview]
Message-ID: <20210615104240.57EF3C433F1@smtp.codeaurora.org> (raw)
In-Reply-To: <20210511235629.1686038-1-linux@roeck-us.net>

Guenter Roeck <linux@roeck-us.net> wrote:

> 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>

Patch applied to wireless-drivers-next.git, thanks.

34fe7038a3b3 brcmsmac: Drop unnecessary NULL check after container_of

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20210511235629.1686038-1-linux@roeck-us.net/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


      reply	other threads:[~2021-06-15 10:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 23:56 [PATCH] brcm80211: Drop unnecessary NULL check after container_of Guenter Roeck
2021-06-15 10:42 ` Kalle Valo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210615104240.57EF3C433F1@smtp.codeaurora.org \
    --to=kvalo@codeaurora.org \
    --cc=aspriel@gmail.com \
    --cc=brcm80211-dev-list.pdl@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).