linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rene Herman <rene.herman@gmail.com>
To: Jesper Juhl <jesper.juhl@gmail.com>
Cc: linux-scsi@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] Re: cciss: warning: right shift count >= width of type
Date: Sun, 12 Aug 2007 03:21:57 +0200	[thread overview]
Message-ID: <46BE60B5.7010708@gmail.com> (raw)
In-Reply-To: <200708120228.26234.jesper.juhl@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]

On 08/12/2007 02:28 AM, Jesper Juhl wrote:

> I've been building some randconfig kernels lately and I've noticed 
> this in a few builds : 
> 
> drivers/block/cciss.c:2614: warning: right shift count >= width of type
> drivers/block/cciss.c:2615: warning: right shift count >= width of type
> drivers/block/cciss.c:2616: warning: right shift count >= width of type
> 
> The code in question is this : 
> 
> static void do_cciss_request(struct request_queue *q)
> {
> ...
>         sector_t start_blk;
> ...
>                         c->Request.CDB[2]= (start_blk >> 56) & 0xff;    //MSB
>                         c->Request.CDB[3]= (start_blk >> 48) & 0xff;
>                         c->Request.CDB[4]= (start_blk >> 40) & 0xff;
> ...
> }
> 
> 
> The problem stems from these lines in include/linux/types.h : 
> ...
> #ifdef CONFIG_LBD
> typedef u64 sector_t;
> #else
> typedef unsigned long sector_t;
> #endif
> ...
> 
> So on a 32bit arch without CONFIG_LBD, sector_t is going to be 32 bits wide.
> Thus it seems gcc is absolutely right in complaining about those 
> 56, 48 & 40 bit shifts, since they are indeed wider than the type 
> in the "!CONFIG_LBD on a 32bit arch" case.
> 
> 
> I must admit that I have no idear what the proper way to deal with 
> that is, so I'll just report it so hopefully someone else can fix it.
> 
> By the way; I'm building current Linus git tree, head at commit 
> ac07860264bd2b18834d3fa3be47032115524cea

Well, given that it's explicitly treating start_blk as a 64-bit value, the 
proper fix is probably to cast start_blk to an actual (guaranteed) 64-bit 
value. Untested, uncompiled, and someone else may disagree:

Rene.

[-- Attachment #2: cciss.diff --]
[-- Type: text/plain, Size: 1174 bytes --]

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 5acc6c4..fa2eec8 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -2609,13 +2609,13 @@ static void do_cciss_request(request_queue_t *q)
 		} else {
 			c->Request.CDBLen = 16;
 			c->Request.CDB[1]= 0;
-			c->Request.CDB[2]= (start_blk >> 56) & 0xff;	//MSB
-			c->Request.CDB[3]= (start_blk >> 48) & 0xff;
-			c->Request.CDB[4]= (start_blk >> 40) & 0xff;
-			c->Request.CDB[5]= (start_blk >> 32) & 0xff;
-			c->Request.CDB[6]= (start_blk >> 24) & 0xff;
-			c->Request.CDB[7]= (start_blk >> 16) & 0xff;
-			c->Request.CDB[8]= (start_blk >>  8) & 0xff;
+			c->Request.CDB[2]= ((u64)start_blk >> 56) & 0xff;	//MSB
+			c->Request.CDB[3]= ((u64)start_blk >> 48) & 0xff;
+			c->Request.CDB[4]= ((u64)start_blk >> 40) & 0xff;
+			c->Request.CDB[5]= ((u64)start_blk >> 32) & 0xff;
+			c->Request.CDB[6]= ((u64)start_blk >> 24) & 0xff;
+			c->Request.CDB[7]= ((u64)start_blk >> 16) & 0xff;
+			c->Request.CDB[8]= ((u64)start_blk >>  8) & 0xff;
 			c->Request.CDB[9]= start_blk & 0xff;
 			c->Request.CDB[10]= (creq->nr_sectors >>  24) & 0xff;
 			c->Request.CDB[11]= (creq->nr_sectors >>  16) & 0xff;

  parent reply	other threads:[~2007-08-12  1:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-12  0:28 cciss: warning: right shift count >= width of type Jesper Juhl
2007-08-12  0:56 ` Jesper Juhl
2007-08-12  1:25   ` [PATCH] " Rene Herman
2007-08-12  1:54     ` Rene Herman
2007-08-12  1:21 ` Rene Herman [this message]
2007-08-12  6:58   ` Al Viro
2007-08-12 19:55     ` Rene Herman
2007-08-12 20:32     ` James Bottomley
2007-08-12 23:08       ` Rene Herman

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=46BE60B5.7010708@gmail.com \
    --to=rene.herman@gmail.com \
    --cc=jesper.juhl@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).