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: <CACVxJT99D3JZvXKUjXnXQKmrzb_DPZ+-qDnu4=uXCw_yB9xQ9g@mail.gmail.com>
Date:	Thu, 24 Sep 2015 17:26:59 +0300
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	Michal Nazarewicz <mina86@...a86.com>
Cc:	Linux Kernel <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	John Stultz <john.stultz@...aro.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
	Ingo Molnar <mingo@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: + kernelh-make-abs-work-with-64-bit-types.patch added to -mm tree

On Thu, Sep 24, 2015 at 4:32 PM, Michal Nazarewicz <mina86@...a86.com> wrote:
> On Wed, Sep 23 2015, Alexey Dobriyan wrote:
>> I've sent kabs() before which didn't go in because it didn't work for
>> INT_MAX et al
>> (don't worry, this abs() doens't as well) but it is nicer that this
>> version in other aspects
>> (hopefully).
>>
>> [PATCH v2] Add kabs()
>> http://marc.info/?l=linux-kernel&m=133518745522740&w=4
>
> Perhaps:
>
> +       (void)(_x)))))));                                               \
>
> instead of:
>
> +       _x))))));                                                       \
>
> at the end.  Since kabs makes no sense for unsigned types it’s best to
> fail with compile-time error than to let user think that the call is
> actually doing something.

I thought so, but the amount of uses like

  unsigned int = abs(unsigned int - unsigned int)

is non trivial. With a few exceptions it is about 170 on
x86_64 allmodconfig. Most of them are correct because abs()
casts to signed first. So if you want to expose such uses,
then you are forced to write

  unsigned int = kabs((int)(unsigned int - unsigned int));

Don't know if it's a good thing.

> Also, you don’t need ({ … }) around the ‘_x < 0 ? -_x : _x’ expression,
> do you?

Seems so, thank you for noticing.
--
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