staging: gpib: Fix inadvertent negative shift
PATCH 1/1 staging: gpib: Fix inadvertent negative shift
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.
--- drivers/staging/gpib/include/amcc5920.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gpib/include/amcc5920.h +1 -1
@@ -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 {
Signature · 1 line
2.47.1
Quoted 21 lines · On Thu, 16 Jan 2025 12:00:14 +0100 Dave Penkler <[email protected]> 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 <[email protected]>--- drivers/staging/gpib/include/amcc5920.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/gpib/include/amcc5920.h +0
-0
drivers/staging/gpib/include/amcc5920.h static const int bits_per_region = 8; · line 25
Quoted 5 lines
drivers/staging/gpib/include/amcc5920.h +1
-1@@ -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
Quoted 3 lines
drivers/staging/gpib/include/amcc5920.h +0
-0};enum amcc_prefetch_bits {
Quoted 25 lines · David Laight
Quoted 22 lines · On Thu, 16 Jan 2025 12:00:14 +0100 Dave Penkler <[email protected]> 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 <[email protected]>--- drivers/staging/gpib/include/amcc5920.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/gpib/include/amcc5920.h +0
-0@@ -22,7 +22,7 @@ static const int bits_per_region = 8;
Quoted 6 lines
drivers/staging/gpib/include/amcc5920.h static const int bits_per_region = 8; · line 25
Quoted 4 lines
drivers/staging/gpib/include/amcc5920.h +1
-1static 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