mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Randy Dunlap <randy.dunlap@oracle.com>
To: Pavel Emelianov <xemul@sw.ru>
Cc: Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devel@openvz.org, Kirill Korotaev <dev@openvz.org>
Subject: Re: [PATCH] Introduce a handy list_first_entry macro
Date: Tue, 17 Apr 2007 10:29:45 -0700	[thread overview]
Message-ID: <20070417102945.052796d5.randy.dunlap@oracle.com> (raw)
In-Reply-To: <4624AD20.6050009@sw.ru>

On Tue, 17 Apr 2007 15:18:56 +0400 Pavel Emelianov wrote:

> There are many places in the kernel where the construction like
> 
>    foo = list_entry(head->next, struct foo_struct, list);
> 
> are used. 
> The code might look more descriptive and neat if using the macro
> 
>    list_first_entry(head, type, member) \
>              list_entry((head)->next, type, member)
> 
> Here is the macro itself and the examples of its usage in the
> generic code. If it will turn out to be useful, I can prepare
> the set of patches to inject in into arch-specific code, drivers,
> networking, etc.
> 
> Signed-off-by: Pavel Emelianov <xemul@openvz.org>
> Signed-off-by: Kirill Korotaev <dev@openvz.org>
> 
> ---
> diff --git a/include/linux/list.h b/include/linux/list.h
> index fd59659..71318fc 100644
> --- a/include/linux/list.h
> +++ b/include/linux/list.h
> @@ -425,6 +425,9 @@ static inline void list_splice_init_rcu(
>  #define list_entry(ptr, type, member) \
>  	container_of(ptr, type, member)
>  
> +#define list_first_entry(ptr, type, member) \
> +	list_entry((ptr)->next, type, member)
> +

Please provide kernel-doc for that like the rest of list.h has.

>  /**
>   * list_for_each	-	iterate over a list
>   * @pos:	the &struct list_head to use as a loop cursor.


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

  parent reply	other threads:[~2007-04-17 17:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-17 11:18 Pavel Emelianov
2007-04-17 15:19 ` Andi Kleen
2007-04-17 17:11 ` Zach Brown
2007-04-17 17:29 ` Randy Dunlap [this message]
2007-04-18 11:42 ` Nikita Danilov

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=20070417102945.052796d5.randy.dunlap@oracle.com \
    --to=randy.dunlap@oracle.com \
    --cc=akpm@osdl.org \
    --cc=dev@openvz.org \
    --cc=devel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xemul@sw.ru \
    /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®