[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADYq+fbHCUigvrTuCLiF1TXN=VEBO42PvHQqvgfmTgJejLqS4Q@mail.gmail.com>
Date: Fri, 11 Apr 2025 08:43:26 +0100
From: Samuel Abraham <abrahamadekunle50@...il.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: outreachy@...ts.linux.dev, julia.lawall@...ia.fr,
gregkh@...uxfoundation.org, linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org, david.laight.linux@...il.com,
dan.carpenter@...aro.org, andy@...nel.org
Subject: Re: [PATCH] staging: rtl8723bs: Replace `& 0xfff` with `% 4096u`
On Thu, Apr 10, 2025 at 6:44 PM Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
>
> On Wed, Apr 9, 2025 at 9:48 PM Abraham Samuel Adekunle
> <abrahamadekunle50@...il.com> wrote:
> >
> > The sequence number is constrained to a range of [0, 4095], which
> > is a total of 4096 values. The bitmask operation using `& 0xfff` is
> > used to perform this wrap-around. While this is functionally correct,
> > it obscures the intended semantic of a 4096-based wrap.
> >
> > Using a modulo operation `% 4096u` makes the wrap-around logic
> > explicit and easier to understand. It clearly signals that the
> > sequence number cycles through a range of 4096 values.
> > It also makes the code robust against potential changes of the 4096
> > upper limit, especially when it becomes a non power-of-2 value while
> > the AND(&) works solely for power-of-2 values.
> >
> > The use of `% 4096u` also guarantees that the modulo operation is
> > performed with unsigned arithmetic, preventing potential issues with
> > the signed types.
> >
> > Found by Coccinelle.
>
> This should be folded to the initial change since it's the same driver
> and values most likely are related to each other.
Okay noted.
>
>
> > $ make drivers/staging/rtl8723bs/core/rtw_xmit.o
> > $ cmp rtw_xmit_before.o rtw_xmit_after.o
>
> cmp is good but not good enough in general. Here it shows the 1:1
> binary, but in some cases code can be the same, while binaries are
> different. To make sure the code is the same use the bloat-o-meter
> tool instead.
Okay, thanks for the suggestion. I will check out the bloat-o-meter tool.
Adekunle.
Powered by blists - more mailing lists