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: <20190118164425.GC3578@e103592.cambridge.arm.com>
Date:   Fri, 18 Jan 2019 16:44:25 +0000
From:   Dave Martin <Dave.Martin@....com>
To:     Russell King - ARM Linux admin <linux@...linux.org.uk>
Cc:     Andrew Murray <andrew.murray@....com>,
        Kees Cook <keescook@...omium.org>,
        Arnd Bergmann <arnd@...db.de>,
        Catalin Marinas <catalin.marinas@....com>, rjw@...ysocki.net,
        linux-kernel@...r.kernel.org, Will Deacon <will.deacon@....com>,
        Steven Price <Steven.Price@....com>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Grant Likely <Grant.Likely@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [Linux-eng] [RFC 0/3] Abstract empty functions with STUB_UNLESS
 macro

On Fri, Jan 18, 2019 at 04:37:36PM +0000, Russell King - ARM Linux admin wrote:
> On Fri, Jan 18, 2019 at 04:00:27PM +0000, Andrew Murray wrote:
> > A common pattern found in header files is a function declaration dependent
> > on a CONFIG_ option being enabled, followed by an empty function for when
> > that option isn't enabled. This boilerplate code can often take up a lot
> > of space and impact code readability.
> > 
> > This series introduces a STUB_UNLESS macro that simplifies header files as
> > follows:
> > 
> > STUB_UNLESS(CONFIG_FOO, [body], prototype)
> 
> Can you explain the desire to make the second argument optional,
> rather than having the mandatory arguments first and the optional body
> last?  It will mean more lines at each site, but I don't think that's
> a bad thing:
> 
> STUB_UNLESS(CONFIG_HAVE_HW_BREAKPOINT,
> void hw_breakpoint_thread_switch(struct task_struct *next));
> 
> STUB_UNLESS(CONFIG_CPU_FREQ,
> struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu), return NULL);
> 
> or:
> 
> STUB_UNLESS(CONFIG_CPU_FREQ,
> struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu),
> 	return NULL);
> 
> Seems to be more readable in terms of the flow.

Hmmm, looking at that, I probably prefer that too.

In the unlikely case that <body> uses the function arguments it would be
quite confusing to have the body before the function prototype.

If we can keep this down to two lines so much the better, but still
seems fine.

Provided we don't end up needing a trailing comma in the void case, to
supply the empty body argument, that is.

Cheers
---Dave

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ