linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Winkler, Tomas" <tomas.winkler@intel.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] mei: Drop unnecessary NULL check after container_of
Date: Tue, 11 May 2021 05:16:41 +0000	[thread overview]
Message-ID: <42c7b18dae6648d69346cc6b77e92178@intel.com> (raw)
In-Reply-To: <20210511045512.2376580-1-linux@roeck-us.net>



> 
> The result of container_of() operations is never NULL unless the embedded
> element is the first element of the data structure, which is not the case here.
> The NULL check is therefore unnecessary and misleading. 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>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
> ---
>  drivers/misc/mei/main.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index
> 28937b6e7e0c..9001c45f6fc4 100644
> --- a/drivers/misc/mei/main.c
> +++ b/drivers/misc/mei/main.c
> @@ -50,8 +50,6 @@ static int mei_open(struct inode *inode, struct file *file)
>  	int err;
> 
>  	dev = container_of(inode->i_cdev, struct mei_device, cdev);
> -	if (!dev)
> -		return -ENODEV;
> 
>  	mutex_lock(&dev->device_lock);
> 
> --
> 2.25.1


      reply	other threads:[~2021-05-11  5:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11  4:55 [PATCH] mei: Drop unnecessary NULL check after container_of Guenter Roeck
2021-05-11  5:16 ` Winkler, Tomas [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=42c7b18dae6648d69346cc6b77e92178@intel.com \
    --to=tomas.winkler@intel.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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).