From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web10.2756.1583836578460856630 for ; Tue, 10 Mar 2020 03:36:18 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H+TJ25RD; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583836577; 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=Z18kEq9LZzBb5jprPf3ZagJbiMFnBg1OC6uRN2+kJ+Y=; b=H+TJ25RDQD/Id0ybF2xjjRcEbqp4S1+shGjq0iWoGecsKwP+FaxtgFHkvNPK0Tv8RjfQaC 2WItxcZMum7tZHp6KfJyiT5R/hxu3Wyn0z5pXqDyTIpVMHIPmEFiTXP353rbOoCeIJTucl TOBlKKf0m421IEaPBkbeAW7h210zV+k= 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-328-RPHIIs9lPY61QNt22REW7A-1; Tue, 10 Mar 2020 06:36:13 -0400 X-MC-Unique: RPHIIs9lPY61QNt22REW7A-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 3C2941005514; Tue, 10 Mar 2020 10:36:12 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-246.ams2.redhat.com [10.36.116.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 653171001B0B; Tue, 10 Mar 2020 10:36:11 +0000 (UTC) Subject: Re: [Patch 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: Cast UNIT64 to UNITN in assignment To: Bob Feng , devel@edk2.groups.io Cc: Ard Biesheuvel References: <20200310084426.29044-1-bob.c.feng@intel.com> From: "Laszlo Ersek" Message-ID: Date: Tue, 10 Mar 2020 11:36:10 +0100 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: <20200310084426.29044-1-bob.c.feng@intel.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/10/20 09:44, Bob Feng wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2580 > > Ovmf build failed on Windows with VS2017 tool chain. > The error message like: > > OvmfPkg\LinuxInitrdDynamicShellCommand\LinuxInitr > dDynamicShellCommand.c(199): error C2220: warning treated as error - > no 'object' file generated > OvmfPkg\LinuxInitrdDynamicShellCommand\LinuxInitrdDynamicShellCommand.c(199): > warning C4244: '=': conversion from 'UINT64' to 'UINTN', > possible loss of data > > This patch is to cast UINT64 type to UINTN type > when doing the variable assignment. > > Signed-off-by: Bob Feng > Cc: Ard Biesheuvel > Cc: Laszlo Ersek > --- > .../LinuxInitrdDynamicShellCommand.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c > index 021b072826a9..07baa0e8d100 100644 > --- a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c > +++ b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c > @@ -194,11 +194,11 @@ CacheInitrdFile ( > &gEfiLoadFile2ProtocolGuid, &mInitrdLoadFile2, > NULL); > ASSERT_EFI_ERROR (Status); > } > > - mInitrdFileSize = FileSize; > + mInitrdFileSize = (UINTN)FileSize; > return EFI_SUCCESS; > > FreeMemory: > gBS->FreePages (mInitrdFileAddress, EFI_SIZE_TO_PAGES ((UINTN)FileSize)); > return Status; > Yes, this patch is safe; the function catches (FileSize > MAX_UINTN) gracefully, near the top. Reviewed-by: Laszlo Ersek Thank you very much for the patch! Laszlo