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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 401C9C433EF for ; Fri, 24 Jun 2022 13:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232193AbiFXNpY convert rfc822-to-8bit (ORCPT ); Fri, 24 Jun 2022 09:45:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbiFXNpU (ORCPT ); Fri, 24 Jun 2022 09:45:20 -0400 Received: from relay5.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42AD72619 for ; Fri, 24 Jun 2022 06:45:18 -0700 (PDT) Received: from omf13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8FBE0348F7; Fri, 24 Jun 2022 13:45:16 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf13.hostedemail.com (Postfix) with ESMTPA id 4145220015; Fri, 24 Jun 2022 13:45:15 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2 01/12] regmap-irq: Convert bool bitfields to unsigned int From: Joe Perches To: Aidan MacDonald Cc: Mark Brown , Andy Shevchenko , Greg Kroah-Hartman , "Rafael J. Wysocki" , Matti Vaittinen , Linux Kernel Mailing List Date: Fri, 24 Jun 2022 06:45:14 -0700 In-Reply-To: References: <20220623211420.918875-1-aidanmacdonald.0x0@gmail.com> <20220623211420.918875-2-aidanmacdonald.0x0@gmail.com> <4937c0cc9dbc9d06cb626465bd37cbcf76c80a0b.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.1-0ubuntu1 MIME-Version: 1.0 X-Stat-Signature: oj1mfyszgctb9y5x9ca7yk88ouwo3wmz X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: 4145220015 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX199JvKTOf4Uzq/iWnRzovqBECkde32PCfU= X-HE-Tag: 1656078315-170775 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2022-06-24 at 14:05 +0100, Aidan MacDonald wrote: > Joe Perches writes: > > > On Fri, 2022-06-24 at 13:11 +0100, Mark Brown wrote: > > > On Thu, Jun 23, 2022 at 11:26:10PM +0200, Andy Shevchenko wrote: > > > > On Thu, Jun 23, 2022 at 11:13 PM Aidan MacDonald > > > > > > > > Use 'unsigned int' for bitfields for consistency with most other > > > > > kernel code. > > > > > > > There is no point to convert the fields you are about to remove. > > > > > > > So, either don't touch them or make this patch closer to the end of the series. > > > > > > It costs us nothing to convert them, this isn't a difficult or hard to > > > understand refactoring - the patch is fine the way it is. > > > > Modulo the defects that might be introduced if an overflow occurs. > > > > struct foo { > > unsigned int a:1; > > bool b:1; > > } > > > > Assign a non-zero int without bit 0 set to each and see if > > a and b differ. > > Bool permits implicit pointer-to-bool conversions, so it isn't free > of pitfalls either. Care to describe some of those pitfalls? I can't think of any off the top of my head. > Overflow is probably more dangerous in general, > but here there's little chance of pointers or overflow getting involved. I don't know _this_ code at all, nor have I read it. If all the conversions are just deleted later, then of course it should not be converted at all. I'm just commenting on the proposed refactoring. I'm trying to show that conversions of bool:1->unsigned int:1 as being trivial are not so trivial after all. It's fairly common to have code like: [bool] foo.bar = some_value & SETTING; where some value is tested for a mask/bit and a non-zero is true. So conversions of foo.bar from bool:1 to unsigned int:1 are not wise unless all possible side effects are known.