lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1280865213.6088.15.camel@Joe-Laptop.home>
Date:	Tue, 03 Aug 2010 12:53:33 -0700
From:	Joe Perches <joe@...ches.com>
To:	Eric Paris <eparis@...hat.com>
Cc:	linux-kernel@...r.kernel.org, selinux@...ho.nsa.gov,
	dave@...ux.vnet.ibm.com, akpm@...ux-foundation.org,
	jmorris@...ei.org, sds@...ho.nsa.gov
Subject: Re: [PATCH] flex_array: add helpers to get and put to make
 pointers easy to use

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@...hat.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)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ