From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 76B97C27C52 for ; Tue, 4 Jun 2024 18:06:34 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Vtz7D577fz3fml for ; Wed, 5 Jun 2024 04:06:32 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2604:1380:4641:c500::1; helo=dfw.source.kernel.org; envelope-from=srs0=dfpp=ng=goodmis.org=rostedt@kernel.org; receiver=lists.ozlabs.org) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Vtw9n69RBz3cNt for ; Wed, 5 Jun 2024 01:53:33 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8618E6134C; Tue, 4 Jun 2024 15:53:25 +0000 (UTC) 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 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) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Wed, 05 Jun 2024 03:59:10 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juri Lelli , Andrew Lunn , "Rafael J. Wysocki" , Heiko Stuebner , "Rafael J. Wysocki" , Takashi Iwai , Viresh Kumar , Linus Walleij , dri-devel@lists.freedesktop.org, Jaroslav Kysela , Ben Segall , Perry Yuan , Prashant Gaikwad , Pavel Machek , Srinivas Pandruvada , linux-clk@vger.kernel.org, Kishon Vijay Abraham I , Abel Wu , Vincent Guittot , Karol Herbst , Samuel Holland , Sebastian Reichel , Tvrtko Ursulin , linux-acpi@vger.kernel.org, Danilo Krummrich , Mel Gorman , linux-sunxi@lists. linux.dev, Guenter Roeck , Jean Delvare , linux-pm@vger.kernel.org, Potnuri Bharat Teja , James Morris , linux-sound@vger.kernel.org, Thomas Gleixner , linux-omap@vger.kernel.org, Zhihao Cheng , Dietmar Eggemann , Niklas Cassel , Scott Branden , Greg Kroah-Hartman , Randy Dunlap , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, "Gautham R. Shenoy" , Dmitry Kasatkin , Tejun Heo , Andrew Morton , Elad Nachman , Linus Torvalds , Lukasz Luba , linux-fbdev@vger.kernel.org, linux-usb@vger.kernel.org, Zefan Li , nouveau@ lists.freedesktop.org, Dave Hansen , Clemens Ladisch , Mimi Zohar , Mahesh J Salgaonkar , Hu Ziji , Eric Dumazet , keyrings@vger.kernel.org, Oliver O'Halloran , linux-i2c@vger.kernel.org, Gregory Greenman , Ingo Molnar , linux-security-module@vger.kernel.org, Valentin Schneider , Corey Minyard , Gregory Clement , Lee Jones , Hugh Dickins , Jonathan Hunter , linux-rockchip@lists.infradead.org, linux-trace-kernel@vger.kernel.org, Andi Shyti , Robert Richter , Maarten Lankhorst , Brian Foster , Maxime Ripard , linux-gpio@vger.kernel.org, Jason Baron , linux-rpi-kernel@lists.infradead.org, Bjorn Helgaas , cgroups@vger.kernel.org, Allen Pais , linux-arm-kernel@lists.infradead.org, Daniel Lezcano , Stephen Boyd , Roberto Sassu , linux-integrity@vger.kernel.org, Daniel Bristot de Oliveira , Len Brown , Heiner Kallweit , Miri Korenblit , Arseniy Krasnov , Ulf Hansson , Heikki Krogerus , Kuninori Morimoto , Alexander Shishkin , linux-pci@vger.kernel.org, Michael Turquette , Joonas Lahtinen , alsa-devel@alsa-project.org, Nuno Sa , Matthias Brugger , linux-mtd@lists .infradead.org, linux-hardening@vger.kernel.org, linux-phy@lists.infradead.org, Jiri Slaby , linux-staging@lists.linux.dev, Jernej Skrabec , Nikita Kravets , Peter Zijlstra , Chen-Yu Tsai , Abdel Alkuor , Broadcom internal kernel review list , "Naveen N. Rao" , Ilpo =?UTF-8?B?SsOkcnZpbmVu?= , Paolo Abeni , "Serge E. Hallyn" , Lyude Paul , Kees Cook , Ray Jui , intel-gfx@lists.freedesktop.org, Johannes Berg , Paul Moore , Mark Brown , Borislav Petkov , Rodrigo Vivi , Stanley Chang , Daniel Vetter , openipmi-developer@list s.sourceforge.net, linux-hwmon@vger.kernel.org, Sergey Shtylyov , linux-mm@kvack.org, Thinh Nguyen , linux-mmc@vger.kernel.org, Sebastian Reichel , Takashi Sakamoto , Daniel Scally , JC Kuo , Thierry Reding , Masami Hiramatsu , Sakari Ailus , "David S. Miller" , Mario Limonciello , Giovanni Cabiddu , Vignesh Raghavendra , Eric Biggers , Tony Lindgren , Takashi Iwai , David Howells , linux-ide@vger.kernel.org, Huang Rui , "H. Peter Anvin" , David Airlie , Jim Cromie , linux-leds@vger.kernel.org, Eric Snowberg , Herbert Xu , Florian Fainelli , Richard Weinberger , x86@kernel.org, qat-linux@intel.com, linux-bcachefs@vger.kernel.org, Ingo Molnar , Chunfeng Yun , Jakub Kicinski , Zhang Rui , Sebastian Hesselbarth , platform-driver-x86@vger.kernel.org, Thomas Zimmermann , Jiapeng Chong , Miquel Raynal , Kalle Valo , apparmor@lists.ubuntu.com, Hans de Goede , linux-mediatek@lists.infradead.org, Nicholas Piggin , Benjamin Berg , linux-tegra@vger.kernel.org, Andy Shevchenko , intel-xe@lists.freedesktop.org, AngeloGioacchino Del Regno , John Johansen , L iam Girdwood , netdev@vger.kernel.org, Peter De Schrijver , Kent Overstreet , Adrian Hunter , Vinod Koul , Damien Le Moal , Daniel Bristot de Oliveira , Johannes Weiner , Mathieu Desnoyers , linuxppc-dev@lists.ozlabs.org, Helge Deller , Stefan Berger Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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