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: <alpine.DEB.2.20.1705261229330.1902@nanos>
Date:   Fri, 26 May 2017 12:31:15 +0200 (CEST)
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Mariusz Skamra <mariuszx.skamra@...el.com>
cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ktime: Simplify ktime_* comparison functions

On Fri, 26 May 2017, Mariusz Skamra wrote:
> -static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2)
> -{
> -	if (cmp1 < cmp2)
> -		return -1;
> -	if (cmp1 > cmp2)
> -		return 1;
> -	return 0;
> -}
> +#define ktime_compare(cmp1, cmp2)	ktime_sub(cmp1, cmp2)

What's wrong with modifying the inline itself?

> -static inline bool ktime_after(const ktime_t cmp1, const ktime_t cmp2)
> -{
> -	return ktime_compare(cmp1, cmp2) > 0;
> -}
> +#define ktime_after(cmp1, cmp2)		(ktime_compare(cmp1, cmp2) > 0)

> -static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2)
> -{
> -	return ktime_compare(cmp1, cmp2) < 0;
> -}
> +#define ktime_before(cmp1, cmp2)	(ktime_compare(cmp1, cmp2) < 0)

Sorry, but those two are just crap. That inline compiles to exactly the
same code as the macro. If not, yell at your compiler people.

Thanks,

	tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ