From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA463148FE6; Tue, 4 Jun 2024 15:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717516406; cv=none; b=J/ElMn9fnrAqKHj3Q04mRBprYqY+wqNGifUYyZiyMFLQLHCTS25Uj41KAD7XE06esu1IlUxJft+wyaIdDyTdhp7T/FBd6BJAtIa87svht6SR53OFyPuN5s0Fk6Vej4j+uOOzbygcSuA+kTNL5UlecU3UpWXjznFhBuuFSNTcJ7Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717516406; c=relaxed/simple; bh=jqzyU34fAZG4/WHYtSv7WuekoSVYXVRfGb6ve0icGKI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p24aUvh2sK+xxHKdgy6Nsc5etRY5CTEgKo1l4S7OjdgLXzMcnrN24i2KecpeN4cQrCEo2G5nkOI5AFT/v/bN9IbHUJb2/eqkeQWsl4pHDIpZORyG//m5nc3Wva1nnddlD6cegodt4qLjznDIf8yAzGpYSrbrXWn6acFsy+qIupw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D41BC2BBFC; Tue, 4 Jun 2024 15:52:38 +0000 (UTC) Date: Tue, 4 Jun 2024 11:52:35 -0400 From: Steven Rostedt To: Jani Nikula Cc: Andy Shevchenko , "Rafael J. Wysocki" , Greg Kroah-Hartman , Corey Minyard , Allen Pais , Sebastian Reichel , Perry Yuan , Giovanni Cabiddu , Herbert Xu , Nuno Sa , Guenter Roeck , Randy Dunlap , Andi Shyti , Heiner Kallweit , Lee Jones , Samuel Holland , Elad Nachman , Arseniy Krasnov , Johannes Berg , Gregory Greenman , Benjamin Berg , Bjorn Helgaas , Robert Richter , Vinod Koul , Chunfeng Yun , Linus Walleij , Hans de Goede , Ilpo =?UTF-8?B?SsOkcnZpbmVu?= , Nikita Kravets , Jiri Slaby , Srinivas Pandruvada , Stanley Chang , Heikki Krogerus , Abdel Alkuor , Kent Overstreet , Eric Biggers , Kees Cook , Ingo Molnar , Daniel Bristot de Oliveira , Andrew Morton , Hugh Dickins , Abel Wu , John Johansen , Mimi Zohar , Stefan Berger , Roberto Sassu , Eric Snowberg , Takashi Iwai , Takashi Sakamoto , Jiapeng Chong , Mark Brown , Kuninori Morimoto , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-acpi@vger.kernel.org, linux-ide@vger.kernel.org, openipmi-developer@lists.sourceforge.net, linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org, qat-linux@intel.com, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-hwmon@vger.kernel.org, linux-i2c@vger.kernel.org, linux-leds@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-omap@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, linux-gpio@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-staging@lists.linux.dev, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-hardening@vger.kernel.org, cgroups@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , David Howells , "David S. Miller" , "Rafael J. Wysocki" , Len Brown , Sergey Shtylyov , Damien Le Moal , Niklas Cassel , Daniel Scally , Sakari Ailus , Michael Turquette , Stephen Boyd , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Heiko Stuebner , Peter De Schrijver , Prashant Gaikwad , Thierry Reding , Jonathan Hunter , Huang Rui , "Gautham R. Shenoy" , Mario Limonciello , Viresh Kumar , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , Karol Herbst , Lyude Paul , Danilo Krummrich , Jean Delvare , Alexander Shishkin , Pavel Machek , Chen-Yu Tsai , Jernej Skrabec , Tony Lindgren , Adrian Hunter , Hu Ziji , Ulf Hansson , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Potnuri Bharat Teja , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Miri Korenblit , Kalle Valo , Mahesh J Salgaonkar , Oliver O'Halloran , Kishon Vijay Abraham I , Matthias Brugger , AngeloGioacchino Del Regno , JC Kuo , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Sebastian Reichel , Daniel Lezcano , Zhang Rui , Lukasz Luba , Thinh Nguyen , Helge Deller , Brian Foster , Zhihao Cheng , Tejun Heo , Zefan Li , Johannes Weiner , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Masami Hiramatsu , Mathieu Desnoyers , Jason Baron , Jim Cromie , Paul Moore , James Morris , "Serge E. Hallyn" , Dmitry Kasatkin , Clemens Ladisch , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Linus Torvalds Subject: Re: [PATCH v1 1/1] treewide: Align match_string() with sysfs_match_string() Message-ID: <20240604115235.044acfd6@gandalf.local.home> In-Reply-To: <87tti9cfry.fsf@intel.com> References: <20240603211538.289765-1-andriy.shevchenko@linux.intel.com> <87tti9cfry.fsf@intel.com> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 04 Jun 2024 10:45:37 +0300 Jani Nikula wrote: > On Sun, 02 Jun 2024, Andy Shevchenko wrote: > > Make two APIs look similar. Hence convert match_string() to be > > a 2-argument macro. In order to avoid unneeded churn, convert > > all users as well. There is no functional change intended. > > Why do we think it's a good idea to increase and normalize the use of > double-underscore function names across the kernel, like > __match_string() in this case? It should mean "reserved for the > implementation, not to be called directly". > > If it's to be used directly, it should be named accordingly, right? > > Being in line with __sysfs_match_string() isn't a great argument alone, > because this adds three times the number of __match_string() calls than > there are __sysfs_match_string() calls. It's not a good model to follow. > Arguably both should be renamed. Agreed. I want to get rid of any functions starting with an underscore except for those that are basically the same function used internally for convenience. Perhaps "match_string_dynamic()"? Where it is used for dynamically allocated arrays without known size. Or, allow a third parameter for dynamic arrays. #define match_string(_a, _s, ...) char _______STR[] = __stringify((__VA_ARGS__)); \ if (sizeof(_______STR) > 3) \ __match_string(_a, _s, ##__VA_ARGS__); \ else \ __match_string(_a, _s, ARRAY_SIZE(_a)); What the above stringify((__VA_ARGS__)) does is to check the size of any args added to match_string(). if there isn't any, it will turn into: "()\0", which is of size 3. If you add an argument, it will be: "()\0", which will have a size greater than three. (trace_printk() does this trick in include/linux/kernel.h). This way, both: match_string(array, sting); or match_string(array, string, size); will work. -- Steve