From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dggrg01-dlp.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D6216219392E7 for ; Mon, 10 Apr 2017 02:40:30 -0700 (PDT) Received: from 172.30.72.56 (EHLO DGGEMA405-HUB.china.huawei.com) ([172.30.72.56]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AMH39998; Mon, 10 Apr 2017 17:40:28 +0800 (CST) Received: from DGGEMA505-MBS.china.huawei.com ([169.254.4.120]) by DGGEMA405-HUB.china.huawei.com ([10.3.20.46]) with mapi id 14.03.0301.000; Mon, 10 Apr 2017 17:40:25 +0800 From: Guoheyi To: "edk2-devel@lists.01.org" CC: Feng Tian , Feng Tian Thread-Topic: [edk2] [ScsiDiskDxe] Implict type conversion bug Thread-Index: AdKx3niUmwxWUOc0RKi079uw2sqbEw== Date: Mon, 10 Apr 2017 09:40:25 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.31.55] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.58EB530C.00A6, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=169.254.4.120, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 81b35b031a0e6eed7c8fc17f0eb71b43 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: [ScsiDiskDxe] Implict type conversion bug X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Apr 2017 09:40:32 -0000 Content-Language: zh-CN Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi folks, In MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c, Line 2757, we have the cod= e as below: ScsiDiskDevice->BlkIo.Media->LastBlock =3D (Capacity10->LastLba3 << 24= ) | (Capacity10->LastLba2 << 16) = | (Capacity10->LastLba1 << 8) = | Capacity10->LastLba0; However, we tested on VS2008 and found that the intermediate result would b= e convert to INT32 then INT64 implicitly, so the result will be sign extend= ed and LastBlock may not be assigned with what is expected. We can simply t= est LastLba3 >=3D 0x80 to see what will happen. Please let me know your comments. Thanks and regards, Gary (Heyi Guo)