public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Joe Perches <joe@perches.com>
Cc: Karolina Drobnik <karolinadrobnik@gmail.com>,
	outreachy-kernel@googlegroups.com, gregkh@linuxfoundation.org,
	forest@alittletooquiet.net, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/8] staging: vt6655: Use incrementation in `idx`
Date: Thu, 4 Nov 2021 20:40:18 +0300	[thread overview]
Message-ID: <20211104174018.GD2794@kadam> (raw)
In-Reply-To: <2fd61a94d8cacd2626364bd25eace6b141ad1766.camel@perches.com>

On Thu, Nov 04, 2021 at 07:44:22AM -0700, Joe Perches wrote:
> On Thu, 2021-11-04 at 16:00 +0300, Dan Carpenter wrote:
> > On Mon, Nov 01, 2021 at 02:32:00PM +0000, Karolina Drobnik wrote:
> > > Increment `idx` in a loop instead of adding the loop counter
> > > `i` to do so. Thanks to this change, the cast to unsigned short
> > > can be removed.
> > > 
> > > Signed-off-by: Karolina Drobnik <karolinadrobnik@gmail.com>
> > > ---
> > >  drivers/staging/vt6655/rf.c | 16 ++++++++--------
> > >  1 file changed, 8 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c
> []
> > > @@ -700,11 +700,11 @@ bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char rf_type,
> > >  			return false;
> > >  
> > >  		for (i = 0; i < CB_AL2230_INIT_SEQ; i++)
> > > -			MACvSetMISCFifo(priv, (unsigned short)(idx + i), al2230_init_table[i]);
> > > +			MACvSetMISCFifo(priv, idx++, al2230_init_table[i]);
> > 
> > Of course, idx is no longer a constant so declaring it as a variable
> > makes sense here.  But maybe just do it in the same patch because the
> > patch 1/1 doesn't make sense as a stand alone patch.
> > 
> > Also don't declare idx as an unsigned short.  It's better to declare it
> > as a int so it just works like a normal number and you don't have to
> > think about signedness bugs and wrapping and edge cases.
> 
> No, IMO it really should be a u16.
> Look at the iowrite16() within the call to MACvSetMISCFifo.

Obviously we all agree it has no effect on runtime at all.

I just think that people get into trouble getting too creative with
their types.  There was some discussion earlier about where the casting
was required (it's not required at all).  It seems like there was some
confusion about how types work.  Declaring it as "unsigned short" has
some documentation value, I guess, but you avoid signedness bugs when
you declare things as int.

I don't care too much, but I also try to tell people not to be fancy.

regards,
dan carpenter

  reply	other threads:[~2021-11-04 17:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 14:31 [PATCH v2 0/8] subject: staging: vt6655: Fix line wrapping in `RFvWriteWakeProgSyn` Karolina Drobnik
2021-11-01 14:31 ` [PATCH v2 1/8] staging: vt6655: Introduce `idx` temporary variable Karolina Drobnik
2021-11-04 12:09   ` Dan Carpenter
2021-11-04 14:33     ` Joe Perches
2021-11-05 12:51       ` Dan Carpenter
2021-11-01 14:32 ` [PATCH v2 2/8] staging: vt6655: Use incrementation in `idx` Karolina Drobnik
2021-11-04 12:15   ` Dan Carpenter
2021-11-04 13:00   ` Dan Carpenter
2021-11-04 14:44     ` Joe Perches
2021-11-04 17:40       ` Dan Carpenter [this message]
2021-11-01 14:32 ` [PATCH v2 3/8] staging: vt6655: Remove unused `i` increments Karolina Drobnik
2021-11-04 13:38   ` Dan Carpenter
2021-11-08  9:57     ` Karolina Drobnik
2021-11-08 10:16       ` Dan Carpenter
2021-11-01 14:32 ` [PATCH v2 4/8] staging: vt6655: Rewrite conditional in AL7320 initialization Karolina Drobnik
2021-11-01 14:32 ` [PATCH v2 5/8] staging: vt6655: Rename `RFvWriteWakeProgSyn` function Karolina Drobnik
2021-11-01 14:32 ` [PATCH v2 6/8] staging: vt6655: Update comment for `rf_write_wake_prog_syn` Karolina Drobnik
2021-11-01 14:32 ` [PATCH v2 7/8] staging: vt6655: Delete bogus check for `init_count` in AL2230 Karolina Drobnik
2021-11-01 14:32 ` [PATCH v2 8/8] staging: vt6655: Delete bogus check for `init_count` in AL7230 Karolina Drobnik

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=20211104174018.GD2794@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=forest@alittletooquiet.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=karolinadrobnik@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=outreachy-kernel@googlegroups.com \
    /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