From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v2] usb: gadget: Drop unnecessary NULL checks after container_of
Date: Sun, 25 Apr 2021 06:08:14 +0300 [thread overview]
Message-ID: <YITdHl3vb5qiCHPC@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20210424145443.170413-1-linux@roeck-us.net>
Hi Guenter,
Thank you for the patch.
On Sat, Apr 24, 2021 at 07:54:43AM -0700, Guenter Roeck wrote:
> The parameters passed to allow_link and drop_link functions are never NULL.
> That means the result of container_of() on those parameters is also
> never NULL, even though the reference into the structure points to the
> first element of the structure. Remove the unnecessary NULL checks.
>
> This change was made automatically with the following Coccinelle script.
> A now obsolete 'out:' label was removed manually.
>
> @@
> type t;
> identifier v;
> statement s;
> @@
>
> <+...
> (
> t v = container_of(...);
> |
> v = container_of(...);
> )
> ...
> when != v
> - if (\( !v \| v == NULL \) ) s
> ...+>
>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Acked-by: Felipe Balbi <balbi@kernel.org>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> v2: Dropped RFC, added Acked-by:, dropped now obsolete 'out:' label
>
> drivers/usb/gadget/function/uvc_configfs.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c
> index 00fb58e50a15..7775f9902360 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.c
> +++ b/drivers/usb/gadget/function/uvc_configfs.c
> @@ -914,8 +914,6 @@ static int uvcg_streaming_header_allow_link(struct config_item *src,
>
> target_fmt = container_of(to_config_group(target), struct uvcg_format,
> group);
> - if (!target_fmt)
> - goto out;
>
> uvcg_format_set_indices(to_config_group(target));
>
> @@ -955,8 +953,6 @@ static void uvcg_streaming_header_drop_link(struct config_item *src,
> mutex_lock(&opts->lock);
> target_fmt = container_of(to_config_group(target), struct uvcg_format,
> group);
> - if (!target_fmt)
> - goto out;
>
> list_for_each_entry_safe(format_ptr, tmp, &src_hdr->formats, entry)
> if (format_ptr->fmt == target_fmt) {
> @@ -968,7 +964,6 @@ static void uvcg_streaming_header_drop_link(struct config_item *src,
>
> --target_fmt->linked;
>
> -out:
> mutex_unlock(&opts->lock);
> mutex_unlock(su_mutex);
> }
--
Regards,
Laurent Pinchart
prev parent reply other threads:[~2021-04-25 3:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-24 14:54 Guenter Roeck
2021-04-25 3:08 ` Laurent Pinchart [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=YITdHl3vb5qiCHPC@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@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
all inboxes | Powered by JetHome®