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: <ZLrAFmyWz7/gtOgF@smile.fi.intel.com>
Date:   Fri, 21 Jul 2023 20:27:50 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>, Nuno Sa <nuno.sa@...log.com>
Subject: Re: [PATCH v2 1/8] iio: core: Add opaque_struct_size() helper and
 use it

On Fri, Jul 21, 2023 at 08:25:12PM +0300, Andy Shevchenko wrote:
> On Fri, Jul 21, 2023 at 08:22:35PM +0300, Andy Shevchenko wrote:
> > On Fri, Jul 21, 2023 at 08:00:15PM +0300, Andy Shevchenko wrote:
> > > Introduce opaque_struct_size() helper, which may be moved
> > > to overflow.h in the future, and use it in the IIO core.

...

> > > +#define opaque_struct_size(p, a, s)	({		\
> > > +	size_t _psize = sizeof(*(p));			\
> > > +	size_t _asize = ALIGN(_psize, (a));		\
> > > +	size_t _ssize = s;				\
> > > +	_ssize ? size_add(_asize, _ssize) : _psize;	\
> > > +})
> > > +
> > > +#define opaque_struct_data(p, a)			\
> > > +	((void *)(p) + ALIGN(sizeof(*(p)), (a)))
> > 
> > Hmm... This can potentially evaluate p twice.
> > 
> > Perhaps this variant is better:
> > 
> > #define opaque_struct_data(p, a)	ALIGN((p) + 1, (a)))
> > 
> > Besides, I don't think we should worry about @s evaluation in the main macro
> > which may be simplified to
> > 
> > #define opaque_struct_size(p, a, s)					\
> > 	((s) ? size_add(ALIGN(sizeof(*(p)), (a)), (s)) : sizeof(*(p)))
> > 
> > Thoughts?
> 
> Also we may leave the struct always be aligned which makes the above even
> simpler (but might waste bytes if @s = 0).
> 
> #define opaque_struct_size(p, a, s)	size_add(ALIGN(sizeof(*(p)), (a)), (s))
> 
> (with the respective documentation update).

Jonathan, this patch can be skipped and if you are okay with the rest, the rest
may be (clearly, I have just checked) applied without as there is no dependency.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ