From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arjan van de Ven Subject: fix corruption in qla1280 Date: Mon, 14 Jul 2003 09:24:37 +0000 Sender: linux-scsi-owner@vger.kernel.org Message-ID: <20030714092437.A4100@devserv.devel.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from nat-pool-rdu.redhat.com ([66.187.233.200]:38409 "EHLO devserv.devel.redhat.com") by vger.kernel.org with ESMTP id S268552AbTGNJJv (ORCPT ); Mon, 14 Jul 2003 05:09:51 -0400 Content-Disposition: inline List-Id: linux-scsi@vger.kernel.org To: akpm@osdl.org, linux-scsi@vger.kernel.org Hi, In C, doing >> 32 on a 32 bit wide variable is undefined behavior, and the code that gets generated by gcc (using the cpu shr) effectively means that it's a nop. The patch below to qla1280.c fixes such a case, doing >>16 twice looks more expensive but gcc optimizes it out while keeping correct behavior. Greetings, Arjan van de Ven --- linux-2.6.0-test1/drivers/scsi/qla1280.c~ 2003-07-14 11:21:51.233657418 +0200 +++ linux-2.6.0-test1/drivers/scsi/qla1280.c 2003-07-14 11:21:51.234657286 +0200 @@ -327,7 +327,7 @@ /* 3.16 */ #ifdef QLA_64BIT_PTR #define pci_dma_lo32(a) (a & 0xffffffff) -#define pci_dma_hi32(a) (a >> 32) +#define pci_dma_hi32(a) ((a >> 16)>>16) #else #define pci_dma_lo32(a) (a & 0xffffffff) #define pci_dma_hi32(a) 0