Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3342614imu; Fri, 18 Jan 2019 08:47:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN7uBxs2NPDnKt4JE7u/XeIlC4zv0os5gCZTEDo3OKwXaJz54GvirDE+iWRW0FpIckd0p72h X-Received: by 2002:a17:902:b595:: with SMTP id a21mr19284233pls.120.1547830044354; Fri, 18 Jan 2019 08:47:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547830044; cv=none; d=google.com; s=arc-20160816; b=RgYzzVJNuYzS6IjLFzHhBcB7Ifo2whDxrWKUVxdJ5jtDV4TJ+Vq8WeUrIvfrzXLo7M ZKOasG5IphVJapu0S6DO5auLYcfEaF+8oSsvUD/YyEb7ZRGnOj3CGc57ouPAdNeTtnGq xngJh8yeSAY+UhTZy3BwWOdgTU0uMHRAUE63inaPo973OtHIeyVDEa5YO/Mi7hFyScIy ZbgEIYuLr4ZbFhqazTGHfDuCXJmFvJ7oWltP+FkJEndRCOXJT1FlOvSBFCJjShw69rYg kQg6RsTltMWEyXfClYHZdYesuULl8YfPt0bJaVzHauo7rJZ8UAQmPIQ6xrRwiYqTIFPt cKpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tzN1k2QfsjfVj/Il8szFm1GCjiETRyARMkpnnT+qkps=; b=I3Hkxw3S5uwT0nxgJXHRSiyH9hfLrXWjJByNBZM5+Ja8IeaIHTIqCFu6FiGIAXi2uC C9bXTGTSdRChvjKRX+Onzegc8Nh52XwrIghzl3iIKZvihM6tb9aKF7GxoTeQtgJAlvAw 52AevOG3Bu7Iwz1M4UoNTgqR+avcC+/iimD6mN82MiXCaLF7YWHP0nxfh5twt8GiaWWq e6zn612tR/Jz3DdJbSJAOjSKNpIbotofFmHVRzmpV0iqcy5+UuNS4pz/6ACihToQA/Gf pM6JQkIOe9aQwGS9g/hZw7Zfv89+1U67b/xboggnb4t27Qy4BXsQOzNLkqFXEbD0HteC OU3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w14si4679654plq.145.2019.01.18.08.47.08; Fri, 18 Jan 2019 08:47:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728063AbfARQob (ORCPT + 99 others); Fri, 18 Jan 2019 11:44:31 -0500 Received: from foss.arm.com ([217.140.101.70]:34128 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727346AbfARQoa (ORCPT ); Fri, 18 Jan 2019 11:44:30 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5636480D; Fri, 18 Jan 2019 08:44:30 -0800 (PST) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1FC653F7BE; Fri, 18 Jan 2019 08:44:27 -0800 (PST) Date: Fri, 18 Jan 2019 16:44:25 +0000 From: Dave Martin To: Russell King - ARM Linux admin Cc: Andrew Murray , Kees Cook , Arnd Bergmann , Catalin Marinas , rjw@rjwysocki.net, linux-kernel@vger.kernel.org, Will Deacon , Steven Price , Masahiro Yamada , Grant Likely , Andrew Morton , linux-arm-kernel@lists.infradead.org Subject: Re: [Linux-eng] [RFC 0/3] Abstract empty functions with STUB_UNLESS macro Message-ID: <20190118164425.GC3578@e103592.cambridge.arm.com> References: <1547827230-55132-1-git-send-email-andrew.murray@arm.com> <20190118163736.6lczivagpsdnm7ju@e5254000004ec.dyn.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190118163736.6lczivagpsdnm7ju@e5254000004ec.dyn.armlinux.org.uk> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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