Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1765255AbXHLBmj (ORCPT ); Sat, 11 Aug 2007 21:42:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757407AbXHLBmN (ORCPT ); Sat, 11 Aug 2007 21:42:13 -0400 Received: from smtpq2.tilbu1.nb.home.nl ([213.51.146.201]:42841 "EHLO smtpq2.tilbu1.nb.home.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753934AbXHLBmJ (ORCPT ); Sat, 11 Aug 2007 21:42:09 -0400 Message-ID: <46BE617D.6010505@gmail.com> Date: Sun, 12 Aug 2007 03:25:17 +0200 From: Rene Herman User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: Jesper Juhl CC: linux-scsi@vger.kernel.org, Linux Kernel Mailing List , Mike Miller , iss_storagedev@hp.com Subject: [PATCH] Re: cciss: warning: right shift count >= width of type References: <200708120228.26234.jesper.juhl@gmail.com> <9a8748490708111756o63ddaeedja091fb2f0b4dbc40@mail.gmail.com> In-Reply-To: <9a8748490708111756o63ddaeedja091fb2f0b4dbc40@mail.gmail.com> Content-Type: multipart/mixed; boundary="------------040809050306030405040304" X-AtHome-MailScanner-Information: Please contact support@home.nl for more information X-AtHome-MailScanner: Found to be clean Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3637 Lines: 101 This is a multi-part message in MIME format. --------------040809050306030405040304 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit On 08/12/2007 02:56 AM, Jesper Juhl wrote: > (whoops, forgot to add maintainer to Cc - now added) Ehm... too late... > On 12/08/07, Jesper Juhl wrote: >> Hi, >> >> 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. --------------040809050306030405040304 Content-Type: text/plain; name="cciss.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cciss.diff" 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; --------------040809050306030405040304-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/