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] [day] [month] [year] [list]
Message-ID: <CACVxJT8=SHXsPTU8EU-ybiNPn7X_aAP=ie0fV4TpmNkzhM4wCw@mail.gmail.com>
Date:	Fri, 8 Jul 2016 13:20:39 +0300
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] make WRITE_ONCE return void

On Fri, Jul 8, 2016 at 11:02 AM, Peter Zijlstra <peterz@...radead.org> wrote:
> On Fri, Jul 08, 2016 at 01:20:08AM +0300, Alexey Dobriyan wrote:
>> Currently WRITE_ONCE is used as if it returns void. Let's codify this
>> before somebody tries to be smarter than necessary.
>>
>> Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
>> ---
>>
>>  include/linux/compiler.h |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> --- a/include/linux/compiler.h
>> +++ b/include/linux/compiler.h
>> @@ -301,7 +301,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
>>       union { typeof(x) __val; char __c[1]; } __u =   \
>>               { .__val = (__force typeof(x)) (val) }; \
>>       __write_once_size(&(x), __u.__c, sizeof(x));    \
>> -     __u.__val;                                      \
>> +     (void)0;                                        \
>>  })
>
> Why then still use the statement expression? Would it not make more
> sense to change it into the regular do { } while (0) form if you want to
> remove the return semantics?

Statement expression is better because it is an expression
so you can write code like

  foo ? WRITE_ONCE(a, 0) : WRITE_ONCE(b, 0)

or

  for (... ; ... ; WRITE_ONCE(a, 0), x++)

"do {} while (0)" should be deprecated really.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ