From: Joe Perches <joe@perches.com>
To: Eric Paris <eparis@redhat.com>
Cc: linux-kernel@vger.kernel.org, selinux@tycho.nsa.gov,
dave@linux.vnet.ibm.com, akpm@linux-foundation.org,
jmorris@namei.org, sds@tycho.nsa.gov
Subject: Re: [PATCH] flex_array: add helpers to get and put to make pointers easy to use
Date: Tue, 03 Aug 2010 12:53:33 -0700 [thread overview]
Message-ID: <1280865213.6088.15.camel@Joe-Laptop.home> (raw)
In-Reply-To: <20100803193623.22126.18019.stgit@paris.rdu.redhat.com>
On Tue, 2010-08-03 at 15:36 -0400, Eric Paris wrote:
> Getting and putting arrays of pointers with flex arrays is a PITA. You
> have to remember to pass &ptr to the _put and you have to do weird and
> wacky casting to get the ptr back from the _get. Add two functions
> flex_array_get_ptr() and flex_array_put_ptr() to handle all of the magic.
>
> Signed-off-by: Eric Paris <eparis@redhat.com>
> ---
>
> include/linux/flex_array.h | 6 ++++++
> lib/flex_array.c | 25 ++++++++++++++++++++++++-
> 2 files changed, 30 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/flex_array.h b/include/linux/flex_array.h
> index 1d747f7..f4e4eb2 100644
> --- a/include/linux/flex_array.h
> +++ b/include/linux/flex_array.h
> @@ -70,4 +70,10 @@ int flex_array_clear(struct flex_array *fa, unsigned int element_nr);
> void *flex_array_get(struct flex_array *fa, unsigned int element_nr);
> int flex_array_shrink(struct flex_array *fa);
>
> +#define flex_array_put_ptr(fa, nr, src, gfp) ({ \
> + void *_src = (src); \
> + flex_array_put((fa), (nr), &_src, (gfp)); \
> + })
Might be nicer to use fewer indents.
Isn't this equivalent?
#define flex_array_put_ptr(fa, nr, src, gfp) \
flex_array_put(fa, nr, &(void *)(src), gfp)
next prev parent reply other threads:[~2010-08-03 19:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-03 19:36 Eric Paris
2010-08-03 19:53 ` Joe Perches [this message]
2010-08-03 20:55 ` David Rientjes
2010-08-03 22:05 ` Eric Paris
2010-08-03 22:43 ` David Rientjes
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=1280865213.6088.15.camel@Joe-Laptop.home \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=dave@linux.vnet.ibm.com \
--cc=eparis@redhat.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/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®