* [PATCH] [SCSI] aacraid: silence two GCC warnings
@ 2013-02-09 20:09 Paul Bolle
2013-02-20 10:40 ` James Bottomley
0 siblings, 1 reply; 4+ messages in thread
From: Paul Bolle @ 2013-02-09 20:09 UTC (permalink / raw)
To: Adaptec OEM Raid Solutions, James E.J. Bottomley; +Cc: linux-scsi, linux-kernel
Compiling src.o for a 32 bit system triggers two GCC warnings:
drivers/scsi/aacraid/src.c: In function ‘aac_src_deliver_message’:
drivers/scsi/aacraid/src.c:410:3: warning: right shift count >= width of type [enabled by default]
drivers/scsi/aacraid/src.c:434:2: warning: right shift count >= width of type [enabled by default]
Silence these warnings by casting the 'address' variable (of type
dma_addr_t) to u64 on those two lines.
Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
---
0) Compile tested only.
1) Changing '0L' to 'OUL' might be a bit of cargo cult programming. I
doubt it's necessary. Members of that cult might also change
'0xffffffff' to '0xffffffffUL', but I didn't.
drivers/scsi/aacraid/src.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c
index 3b021ec..dfa8a37 100644
--- a/drivers/scsi/aacraid/src.c
+++ b/drivers/scsi/aacraid/src.c
@@ -407,7 +407,7 @@ static int aac_src_deliver_message(struct fib *fib)
fib->hw_fib_va->header.StructType = FIB_MAGIC2;
fib->hw_fib_va->header.SenderFibAddress = (u32)address;
fib->hw_fib_va->header.u.TimeStamp = 0;
- BUG_ON((u32)(address >> 32) != 0L);
+ BUG_ON(((u64)address >> 32) != 0UL);
address |= fibsize;
} else {
/* Calculate the amount to the fibsize bits */
@@ -431,7 +431,7 @@ static int aac_src_deliver_message(struct fib *fib)
address |= fibsize;
}
- src_writel(dev, MUnit.IQ_H, (address >> 32) & 0xffffffff);
+ src_writel(dev, MUnit.IQ_H, ((u64)address >> 32) & 0xffffffff);
src_writel(dev, MUnit.IQ_L, address & 0xffffffff);
return 0;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [SCSI] aacraid: silence two GCC warnings
2013-02-09 20:09 [PATCH] [SCSI] aacraid: silence two GCC warnings Paul Bolle
@ 2013-02-20 10:40 ` James Bottomley
2013-02-20 11:01 ` Paul Bolle
0 siblings, 1 reply; 4+ messages in thread
From: James Bottomley @ 2013-02-20 10:40 UTC (permalink / raw)
To: Paul Bolle; +Cc: Adaptec OEM Raid Solutions, linux-scsi, linux-kernel
On Sat, 2013-02-09 at 21:09 +0100, Paul Bolle wrote:
> Compiling src.o for a 32 bit system triggers two GCC warnings:
> drivers/scsi/aacraid/src.c: In function ‘aac_src_deliver_message’:
> drivers/scsi/aacraid/src.c:410:3: warning: right shift count >= width of type [enabled by default]
> drivers/scsi/aacraid/src.c:434:2: warning: right shift count >= width of type [enabled by default]
>
> Silence these warnings by casting the 'address' variable (of type
> dma_addr_t) to u64 on those two lines.
>
> Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
> ---
> 0) Compile tested only.
>
> 1) Changing '0L' to 'OUL' might be a bit of cargo cult programming. I
> doubt it's necessary. Members of that cult might also change
> '0xffffffff' to '0xffffffffUL', but I didn't.
>
> drivers/scsi/aacraid/src.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c
> index 3b021ec..dfa8a37 100644
> --- a/drivers/scsi/aacraid/src.c
> +++ b/drivers/scsi/aacraid/src.c
> @@ -407,7 +407,7 @@ static int aac_src_deliver_message(struct fib *fib)
> fib->hw_fib_va->header.StructType = FIB_MAGIC2;
> fib->hw_fib_va->header.SenderFibAddress = (u32)address;
> fib->hw_fib_va->header.u.TimeStamp = 0;
> - BUG_ON((u32)(address >> 32) != 0L);
> + BUG_ON(((u64)address >> 32) != 0UL);
Actually, this isn't the right way to do this. The correct way would be
address >> 16 >> 16, but no-one is expected to remember this, so we have
it macroised in kernel.h as upper_32_bits().
So this should become
BUG_ON(upper_32_bits(address) != 0L);
and a similar change for the below.
James
> address |= fibsize;
> } else {
> /* Calculate the amount to the fibsize bits */
> @@ -431,7 +431,7 @@ static int aac_src_deliver_message(struct fib *fib)
> address |= fibsize;
> }
>
> - src_writel(dev, MUnit.IQ_H, (address >> 32) & 0xffffffff);
> + src_writel(dev, MUnit.IQ_H, ((u64)address >> 32) & 0xffffffff);
> src_writel(dev, MUnit.IQ_L, address & 0xffffffff);
>
> return 0;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [SCSI] aacraid: silence two GCC warnings
2013-02-20 10:40 ` James Bottomley
@ 2013-02-20 11:01 ` Paul Bolle
2013-02-21 11:39 ` [PATCH v2] [SCSI] aacraid: suppress " Paul Bolle
0 siblings, 1 reply; 4+ messages in thread
From: Paul Bolle @ 2013-02-20 11:01 UTC (permalink / raw)
To: James Bottomley
Cc: Adaptec OEM Raid Solutions, linux-scsi, linux-kernel, akpm
On Wed, 2013-02-20 at 10:40 +0000, James Bottomley wrote:
> On Sat, 2013-02-09 at 21:09 +0100, Paul Bolle wrote:
> > --- a/drivers/scsi/aacraid/src.c
> > +++ b/drivers/scsi/aacraid/src.c
> > @@ -407,7 +407,7 @@ static int aac_src_deliver_message(struct fib *fib)
> > fib->hw_fib_va->header.StructType = FIB_MAGIC2;
> > fib->hw_fib_va->header.SenderFibAddress = (u32)address;
> > fib->hw_fib_va->header.u.TimeStamp = 0;
> > - BUG_ON((u32)(address >> 32) != 0L);
> > + BUG_ON(((u64)address >> 32) != 0UL);
>
> Actually, this isn't the right way to do this. The correct way would be
> address >> 16 >> 16, but no-one is expected to remember this, so we have
> it macroised in kernel.h as upper_32_bits().
>
> So this should become
>
> BUG_ON(upper_32_bits(address) != 0L);
Thanks. I hadn't yet stumbled onto that macro.
> and a similar change for the below.
I hope to send an updated patch shortly.
Paul Bolle
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] [SCSI] aacraid: suppress two GCC warnings
2013-02-20 11:01 ` Paul Bolle
@ 2013-02-21 11:39 ` Paul Bolle
0 siblings, 0 replies; 4+ messages in thread
From: Paul Bolle @ 2013-02-21 11:39 UTC (permalink / raw)
To: Adaptec OEM Raid Solutions, James Bottomley
Cc: linux-scsi, linux-kernel, akpm
Building src.o for a 32 bit system triggers two GCC warnings:
drivers/scsi/aacraid/src.c: In function ‘aac_src_deliver_message’:
drivers/scsi/aacraid/src.c:410:3: warning: right shift count >= width of type [enabled by default]
drivers/scsi/aacraid/src.c:434:2: warning: right shift count >= width of type [enabled by default]
These warnings are caused by a right shift of 32. Use upper_32_bits() to
suppress them.
Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
---
0) Instead of a cast to u64, this version uses upper_32_bits() as James
suggested. I also stopped changing 0L to 0UL, because I keep having
doubts about the cargo cult.
1) Still compile tested only, but now on v3.8.
drivers/scsi/aacraid/src.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c
index 3b021ec..e2e3492 100644
--- a/drivers/scsi/aacraid/src.c
+++ b/drivers/scsi/aacraid/src.c
@@ -407,7 +407,7 @@ static int aac_src_deliver_message(struct fib *fib)
fib->hw_fib_va->header.StructType = FIB_MAGIC2;
fib->hw_fib_va->header.SenderFibAddress = (u32)address;
fib->hw_fib_va->header.u.TimeStamp = 0;
- BUG_ON((u32)(address >> 32) != 0L);
+ BUG_ON(upper_32_bits(address) != 0L);
address |= fibsize;
} else {
/* Calculate the amount to the fibsize bits */
@@ -431,7 +431,7 @@ static int aac_src_deliver_message(struct fib *fib)
address |= fibsize;
}
- src_writel(dev, MUnit.IQ_H, (address >> 32) & 0xffffffff);
+ src_writel(dev, MUnit.IQ_H, upper_32_bits(address) & 0xffffffff);
src_writel(dev, MUnit.IQ_L, address & 0xffffffff);
return 0;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-21 11:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-09 20:09 [PATCH] [SCSI] aacraid: silence two GCC warnings Paul Bolle
2013-02-20 10:40 ` James Bottomley
2013-02-20 11:01 ` Paul Bolle
2013-02-21 11:39 ` [PATCH v2] [SCSI] aacraid: suppress " Paul Bolle
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).