linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Cc: Mark Brown <broonie@kernel.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Matti Vaittinen <mazziesaccount@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 01/12] regmap-irq: Convert bool bitfields to unsigned int
Date: Fri, 24 Jun 2022 06:45:14 -0700	[thread overview]
Message-ID: <ca26910886a765dd7edc4815ef90bedbd0f99a95.camel@perches.com> (raw)
In-Reply-To: <Z2ggoG49naOiT1BMxPbsMc2zOjAUEnha@localhost>

On Fri, 2022-06-24 at 14:05 +0100, Aidan MacDonald wrote:
> Joe Perches <joe@perches.com> 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.


  reply	other threads:[~2022-06-24 13:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 21:14 [PATCH v2 00/12] regmap-irq cleanups and refactoring Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 01/12] regmap-irq: Convert bool bitfields to unsigned int Aidan MacDonald
2022-06-23 21:26   ` Andy Shevchenko
2022-06-24 12:11     ` Mark Brown
2022-06-24 12:46       ` Joe Perches
2022-06-24 12:56         ` Mark Brown
2022-06-24 13:05         ` Aidan MacDonald
2022-06-24 13:45           ` Joe Perches [this message]
2022-06-24 14:28             ` David Laight
2022-06-24 14:31             ` Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 02/12] regmap-irq: Remove unused type_reg_stride field Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 03/12] regmap-irq: Cleanup sizeof(...) use in memory allocation Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 04/12] regmap-irq: Remove an unnecessary restriction on type_in_mask Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 05/12] regmap-irq: Remove inappropriate uses of regmap_irq_update_bits() Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 06/12] regmap-irq: Remove mask_writeonly and regmap_irq_update_bits() Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 07/12] regmap-irq: Refactor checks for status bulk read support Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 08/12] regmap-irq: Introduce config registers for irq types Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 09/12] regmap-irq: Deprecate type registers and virtual registers Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 10/12] regmap-irq: Fix inverted handling of unmask registers Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 11/12] regmap-irq: Add get_irq_reg() callback Aidan MacDonald
     [not found]   ` <CGME20220701163330eucas1p13456e7757d9d2bc8d0aa35c16f143590@eucas1p1.samsung.com>
2022-07-01 16:33     ` Marek Szyprowski
2022-07-03 11:06       ` Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 12/12] regmap-irq: Deprecate the not_fixed_stride flag Aidan MacDonald
2022-06-30 17:27 ` [PATCH v2 00/12] regmap-irq cleanups and refactoring Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ca26910886a765dd7edc4815ef90bedbd0f99a95.camel@perches.com \
    --to=joe@perches.com \
    --cc=aidanmacdonald.0x0@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).