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: <20160920094223.GR5012@twins.programming.kicks-ass.net>
Date:   Tue, 20 Sep 2016 11:42:23 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Marc Zyngier <marc.zyngier@....com>
Cc:     linux-kernel@...r.kernel.org, Jason Baron <jbaron@...mai.com>,
        Jonathan Corbet <corbet@....net>,
        Christoffer Dall <christoffer.dall@...aro.org>,
        Vladimir Murzin <vladimir.murzin@....com>,
        Catalin Marinas <catalin.marinas@....com>
Subject: Re: [PATCH 1/2] jump_labels: Add API to deal with keys embedded in
 structures

On Mon, Sep 19, 2016 at 06:21:27PM +0100, Marc Zyngier wrote:
> It is desirable to allow static keys to be integrated in structures,
> as it can lead do slightly more readable code. But the current API
> only provides DEFINE_STATIC_KEY_TRUE/FALSE, which is not exactly
> nice and leads to the following idiom:
> 
> 	static struct {
> 		int			foo;
> 		struct static_key_false	key;
> 	} bar = {
> 		.key	= STATIC_KEY_FALSE_INIT,
> 	};
> 
> 	[...]
> 
> 	if (static_branch_unlikely(&bar.key))
> 		foo = -1;
> 
> which doesn't follow the recommended API, and uses the internals
> of the static key implementation.
> 
> This patch introduces DECLARE_STATIC_KEY_TRUE/FALSE, as well as
> INIT_STATIC_KEY_TRUE/FALSE, which abstract such construct and
> allow the internals to evolve without having to fix everything else:
> 
> 	static struct {
> 		int			 foo;
> 		DECLARE_STATIC_KEY_FALSE(key);
> 	} bar = {
> 		INIT_STATIC_KEY_FALSE(.key),
> 	};

Hurm..

I think I like the first better, it looks more like actual C. Either way
around you need to now manually match up the type and initializer.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ