Return-Path: MIME-Version: 1.0 Sender: linus971@gmail.com In-Reply-To: <20150915094509.46cca84d@gandalf.local.home> References: <9b705747a138c96c26faee5218f7b47403195b28.1442305897.git.viresh.kumar@linaro.org> <27d37898b4be6b9b9f31b90135f8206ca079a868.1442305897.git.viresh.kumar@linaro.org> <1442313464.1914.21.camel@sipsolutions.net> <20150915110447.GI6350@linux> <20150915094509.46cca84d@gandalf.local.home> Date: Tue, 15 Sep 2015 10:38:32 -0700 Message-ID: Subject: Re: [PATCH V3 2/2] debugfs: don't assume sizeof(bool) to be 4 bytes From: Linus Torvalds To: Steven Rostedt Cc: Viresh Kumar , Johannes Berg , "gregkh@linuxfoundation.org" , "linaro-kernel@lists.linaro.org" , Rafael Wysocki , "sboyd@codeaurora.org" , "arnd@arndb.de" , Mark Brown , Akinobu Mita , Alexander Duyck , "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Andrew Morton , Andy Lutomirski , Arik Nemtsov , "open list:QUALCOMM ATHEROS ATH10K WIRELESS DRIVER" , "open list:QUALCOMM ATHEROS ATH9K WIRELESS DRIVER" , "Altman, Avri" , "open list:B43 WIRELESS DRIVER" , Borislav Petkov , Brian Silverman , Catalin Marinas , Charles Keepax , "Ivgi, Chaya Rachel" , Davidlohr Bueso , Dmitry Monakhov , Doug Thompson , Eliad Peller , "Grumbach, Emmanuel" , Florian Fainelli , Gustavo Padovan , Haggai Eran , Hariprasad S , Ingo Molnar , Intel Linux Wireless , "open list:AMD IOMMU (AMD-VI)" , "James E.J. Bottomley" , Jaroslav Kysela , Jiri Slaby , Joe Perches , Joerg Roedel , Johan Hedberg , Johannes Weiner , Jonathan Corbet , Joonsoo Kim , Kalle Valo , Larry Finger , Len Brown , Liam Girdwood , "open list:ACPI" , "moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)" , "open list:BLUETOOTH DRIVERS" , "open list:DOCUMENTATION" , "open list:EDAC-CORE" , open list , "open list:MEMORY MANAGEMENT" , "open list:CISCO SCSI HBA DRIVER" , "open list:ULTRA-WIDEBAND (UWB) SUBSYSTEM:" , "open list:NETWORKING DRIVERS (WIRELESS)" , "Coelho, Luciano" , "Luis R. Rodriguez" , Marcel Holtmann , Mauro Carvalho Chehab , Mel Gorman , Michael Kerrisk , Michal Hocko , Narsimhulu Musini , "open list:CXGB4 ETHERNET DRIVER (CXGB4)" , Nick Kossifidis , "open list:WOLFSON MICROELECTRONICS DRIVERS" , Peter Zijlstra , QCA ath9k Development , Richard Fitzgerald , Sasha Levin , Sebastian Andrzej Siewior , Sebastian Ott , Sesidhar Baddela , Stanislaw Gruszka , Takashi Iwai , Tejun Heo , Thomas Gleixner , "Winkler, Tomas" , Vlastimil Babka , Wang Long , Will Deacon Content-Type: text/plain; charset=UTF-8 List-ID: On Tue, Sep 15, 2015 at 6:45 AM, Steven Rostedt wrote: > > Linus, This patch changes a lot of u32s into bools in structures. > What's your take on that? So in general, I'd tend to prefer "bool" to be used primarily as a return value for functions, but I have to say, in the case of something that is explicitly called "debugfs_create_bool()" it kind of makes sense to actually take a bool pointer. In structures, it depends a bit on usage. If the intent is to pack things better, I tend to prefer using "char" etc that is explicitly a byte. Or just use explicit bits in an "unsigned int flags" or something. Because while "bool" is _typically_ one byte, but it's very very explicitly documented to not be guaranteed that way, and there are legacy models where "bool" ends up being "int". But in this case, the use of "bool" is not about packing or anything like that, it is more about the logical data type for "debugfs_create_bool()", and so I don't mind "bool" in this context even in structures. But exactly because of the whole ambiguoity about "bool", what I do *not* want to see in any way is "bool" in structures that are exported to user space. That's when we want primarily those explicitly sized types like "u32" etc. We should generally try to avoid even things like "int" in those kinds of structures, and bool is even _less_ well defined than "int" is. But that user interface issue doesn't seem to be the case here, an I can't say that I mind the patch. It looks fairly sane. Linus