* [PATCH] staging: gpib: Fix inadvertent negative shift
@ 2025-01-16 11:00 Dave Penkler
2025-01-16 22:40 ` David Laight
0 siblings, 1 reply; 3+ messages in thread
From: Dave Penkler @ 2025-01-16 11:00 UTC (permalink / raw)
To: gregkh, linux-staging, linux-kernel; +Cc: Dave Penkler
During the initial checkpatch cleanup, when removing blanks
after open parentheses, a minus sign in the argument of a shift
operation was deleted by mistake. This transformed a pre-decrement
operation into a negation.
The result of a negative shift is undefined and a warning was
signalled by sparse.
Restore the pre-decrement operation.
Fixes: 6c52d5e3cde2 ("staging: gpib: Add common include files for GPIB drivers")
Signed-off-by: Dave Penkler <dpenkler@gmail.com>
---
drivers/staging/gpib/include/amcc5920.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/gpib/include/amcc5920.h b/drivers/staging/gpib/include/amcc5920.h
index 766b3799223f..7a88bd282feb 100644
--- a/drivers/staging/gpib/include/amcc5920.h
+++ b/drivers/staging/gpib/include/amcc5920.h
@@ -22,7 +22,7 @@ static const int bits_per_region = 8;
static inline uint32_t amcc_wait_state_bits(unsigned int region, unsigned int num_wait_states)
{
- return (num_wait_states & 0x7) << (-region * bits_per_region);
+ return (num_wait_states & 0x7) << (--region * bits_per_region);
};
enum amcc_prefetch_bits {
--
2.47.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: gpib: Fix inadvertent negative shift
2025-01-16 11:00 [PATCH] staging: gpib: Fix inadvertent negative shift Dave Penkler
@ 2025-01-16 22:40 ` David Laight
2025-01-17 17:55 ` Dave Penkler
0 siblings, 1 reply; 3+ messages in thread
From: David Laight @ 2025-01-16 22:40 UTC (permalink / raw)
To: Dave Penkler; +Cc: gregkh, linux-staging, linux-kernel
On Thu, 16 Jan 2025 12:00:14 +0100
Dave Penkler <dpenkler@gmail.com> wrote:
> During the initial checkpatch cleanup, when removing blanks
> after open parentheses, a minus sign in the argument of a shift
> operation was deleted by mistake. This transformed a pre-decrement
> operation into a negation.
>
> The result of a negative shift is undefined and a warning was
> signalled by sparse.
>
> Restore the pre-decrement operation.
>
> Fixes: 6c52d5e3cde2 ("staging: gpib: Add common include files for GPIB drivers")
> Signed-off-by: Dave Penkler <dpenkler@gmail.com>
> ---
> drivers/staging/gpib/include/amcc5920.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/gpib/include/amcc5920.h b/drivers/staging/gpib/include/amcc5920.h
> index 766b3799223f..7a88bd282feb 100644
> --- a/drivers/staging/gpib/include/amcc5920.h
> +++ b/drivers/staging/gpib/include/amcc5920.h
> @@ -22,7 +22,7 @@ static const int bits_per_region = 8;
>
> static inline uint32_t amcc_wait_state_bits(unsigned int region, unsigned int num_wait_states)
> {
> - return (num_wait_states & 0x7) << (-region * bits_per_region);
> + return (num_wait_states & 0x7) << (--region * bits_per_region);
It would be much better to use (region - 1).
David
> };
>
> enum amcc_prefetch_bits {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: gpib: Fix inadvertent negative shift
2025-01-16 22:40 ` David Laight
@ 2025-01-17 17:55 ` Dave Penkler
0 siblings, 0 replies; 3+ messages in thread
From: Dave Penkler @ 2025-01-17 17:55 UTC (permalink / raw)
To: David Laight; +Cc: gregkh, linux-staging, linux-kernel
On Thu, Jan 16, 2025 at 10:40:03PM +0000, David Laight wrote:
> On Thu, 16 Jan 2025 12:00:14 +0100
> Dave Penkler <dpenkler@gmail.com> wrote:
>
> > During the initial checkpatch cleanup, when removing blanks
> > after open parentheses, a minus sign in the argument of a shift
> > operation was deleted by mistake. This transformed a pre-decrement
> > operation into a negation.
> >
> > The result of a negative shift is undefined and a warning was
> > signalled by sparse.
> >
> > Restore the pre-decrement operation.
> >
> > Fixes: 6c52d5e3cde2 ("staging: gpib: Add common include files for GPIB drivers")
> > Signed-off-by: Dave Penkler <dpenkler@gmail.com>
> > ---
> > drivers/staging/gpib/include/amcc5920.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/gpib/include/amcc5920.h b/drivers/staging/gpib/include/amcc5920.h
> > index 766b3799223f..7a88bd282feb 100644
> > --- a/drivers/staging/gpib/include/amcc5920.h
> > +++ b/drivers/staging/gpib/include/amcc5920.h
> > @@ -22,7 +22,7 @@ static const int bits_per_region = 8;
> >
> > static inline uint32_t amcc_wait_state_bits(unsigned int region, unsigned int num_wait_states)
> > {
> > - return (num_wait_states & 0x7) << (-region * bits_per_region);
> > + return (num_wait_states & 0x7) << (--region * bits_per_region);
>
> It would be much better to use (region - 1).
Hi,
You are right. I will send a separate patch to change this instance and
all the others in the file.
cheers,
-dave
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-17 17:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-16 11:00 [PATCH] staging: gpib: Fix inadvertent negative shift Dave Penkler
2025-01-16 22:40 ` David Laight
2025-01-17 17:55 ` Dave Penkler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox