From: Sergei Shtylyov <sergei.shtylyov@gmail.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-renesas-soc@vger.kernel.org,
Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Subject: Re: [PATCH 1/2] list: Add list_is_null() to check if a list_head has been initialized
Date: Sat, 27 Feb 2021 12:14:55 +0300 [thread overview]
Message-ID: <5272a97f-b221-82f0-f1ee-10eccd05fc09@gmail.com> (raw)
In-Reply-To: <20210226224938.18166-1-laurent.pinchart@ideasonboard.com>
Hello!
On 27.02.2021 1:49, Laurent Pinchart wrote:
> From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
>
> The new function checks if the list_head prev and next pointers are
> NULL, in order to see if a list_head that has been zeroed when allocated
> has been initialized with INIT_LIST_HEAD() or added to a list.
So zeroed or initialized/added? :-)
> This can be used in cleanup functions that want to support being safely
> called when an object has not been initialized, to return immediately.
> In most cases other fields of the object can be checked for this
> purpose, but in some cases a list_head field is the only option.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> include/linux/list.h | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/include/linux/list.h b/include/linux/list.h
> index 85c92555e31f..e4fc6954de3b 100644
> --- a/include/linux/list.h
> +++ b/include/linux/list.h
> @@ -29,6 +29,19 @@ static inline void INIT_LIST_HEAD(struct list_head *list)
> list->prev = list;
> }
>
> +/**
> + * list_is_null - check if a list_head has been initialized
> + * @list: the list
> + *
> + * Check if the list_head prev and next pointers are NULL. This is useful to
> + * see if a list_head that has been zeroed when allocated has been initialized
> + * with INIT_LIST_HEAD() or added to a list.
So zeroed or initialized/added? :-)
> + */
> +static inline bool list_is_null(struct list_head *list)
> +{
> + return list->prev == NULL && list->next == NULL;
Maybe instead:
return !list->prev && !list->next;
[...]
MBR, Sergei
next prev parent reply other threads:[~2021-02-27 9:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-26 22:49 Laurent Pinchart
2021-02-26 22:49 ` [PATCH 2/2] media: v4l2-async: Safely unregister an non-registered async subdev Laurent Pinchart
2021-03-01 8:33 ` Sakari Ailus
2021-02-27 9:14 ` Sergei Shtylyov [this message]
2021-03-01 8:31 ` [PATCH 1/2] list: Add list_is_null() to check if a list_head has been initialized Sakari Ailus
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=5272a97f-b221-82f0-f1ee-10eccd05fc09@gmail.com \
--to=sergei.shtylyov@gmail.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
/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®