From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web10.8871.1585752389823066685 for ; Wed, 01 Apr 2020 07:46:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fL9xt2b5; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585752389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wb8r02I7uTNqqkZLAlqo2QayQ56BUjsw3r2HMnZlhig=; b=fL9xt2b5KWt4nysm1+pxhhV3haAwyv+m7XJxCBCpKQbvvB8t1vheeNNvm5yaBRkJjCrM6V jFrLi9+ouroQrKNbbRlZgQin5x6JxVemdWlDsTWoKehaZgqEXWnYTHCOeojAsMDJQ9oojZ gm2HMykU5Q6iwYazHwm+/0XO89vw4kU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-Md3zeKmMMjCxuypEbSscZg-1; Wed, 01 Apr 2020 10:46:22 -0400 X-MC-Unique: Md3zeKmMMjCxuypEbSscZg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9BA458017CE; Wed, 1 Apr 2020 14:46:20 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-94.ams2.redhat.com [10.36.114.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8CA710016EB; Wed, 1 Apr 2020 14:46:18 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH] OvmfPkg/PvScsiDxe: Fix VS2019 build error because of implicit cast To: devel@edk2.groups.io, liran.alon@oracle.com Cc: sean.brogan@microsoft.com, nikita.leshchenko@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, ard.biesheuvel@linaro.org References: <20200331110452.51992-1-liran.alon@oracle.com> From: "Laszlo Ersek" Message-ID: Date: Wed, 1 Apr 2020 16:46:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200331110452.51992-1-liran.alon@oracle.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 03/31/20 13:04, Liran Alon wrote: > Sean reported that VS2019 build produce the following build error: > INFO - PvScsi.c > INFO - Generating code > INFO - d:\a\1\s\OvmfPkg\PvScsiDxe\PvScsi.c(459): error C2220: the following warning is treated as an error > INFO - d:\a\1\s\OvmfPkg\PvScsiDxe\PvScsi.c(459): warning C4244: '=': conversion from 'const UINT16' to 'UINT8', possible loss of data > > This result from an implicit cast from PVSCSI Response->ScsiStatus > (Which is UINT16) to Packet->TargetResponse (Which is UINT8). > > Fix this issue by adding an appropriate explicit cast and verify with > assert that this truncation do not result in loss of data. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2651 > Reported-by: Sean Brogan > Signed-off-by: Liran Alon > --- > OvmfPkg/PvScsiDxe/PvScsi.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c > index 0a66c98421a9..1ca50390c0e5 100644 > --- a/OvmfPkg/PvScsiDxe/PvScsi.c > +++ b/OvmfPkg/PvScsiDxe/PvScsi.c > @@ -455,8 +455,12 @@ HandleResponse ( > > // > // Report target status > + // (Strangely, PVSCSI interface defines Response->ScsiStatus as UINT16. > + // But it should de-facto always have a value that fits UINT8. To avoid > + // unexpected behavior, verify value is in UINT8 bounds before casting) > // > - Packet->TargetStatus = Response->ScsiStatus; > + ASSERT (Response->ScsiStatus <= MAX_UINT8); > + Packet->TargetStatus = (UINT8)Response->ScsiStatus; > > // > // Host adapter status and function return value depend on > Pushed as commit 98936dc4f44b4ef47e7221d435de06a0813aa00a, via . Thanks, Laszlo