From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 5203F941116 for ; Tue, 16 Jan 2024 06:27:18 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=nMKKz5u7UnlSHzVDXi3CKfu20RPcuBqNnWreRppDUZ8=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1705386437; v=1; b=xBPsnZE8M6RwPHhG+6hEAqQNi+1hrY7K3PnIR/GRBgJ2XdwEYgBt4pXSqGQhBRp9iY7VnX4l 9N4t8kk6kwcUPQLBqyAknZsIfrGOc5es3RHkxSTY9a++8lKRCsxZ3zxj1ApxY1y7uonPmJRHLdY flHFF5+xCEFlcbPZeO6/QjV4= X-Received: by 127.0.0.2 with SMTP id K4LQYY7687511xgP8Jw6tvQc; Mon, 15 Jan 2024 22:27:17 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.91972.1705346436967133618 for ; Mon, 15 Jan 2024 11:20:37 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-ia2cFnSiNCyTTk73hkOZJg-1; Mon, 15 Jan 2024 14:20:34 -0500 X-MC-Unique: ia2cFnSiNCyTTk73hkOZJg-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E5D51C0514B for ; Mon, 15 Jan 2024 19:20:34 +0000 (UTC) X-Received: from [10.39.193.170] (unknown [10.39.193.170]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BF85492BC7; Mon, 15 Jan 2024 19:20:33 +0000 (UTC) Message-ID: <55e5b50e-b635-9cef-7d24-56bfce40d746@redhat.com> Date: Mon, 15 Jan 2024 20:20:32 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2 1/6] OvmfPkg/VirtNorFlashDxe: add casts to UINTN and UINT32 To: Gerd Hoffmann , devel@edk2.groups.io Cc: oliver@redhat.com References: <20240115155948.136499-1-kraxel@redhat.com> <20240115155948.136499-2-kraxel@redhat.com> From: "Laszlo Ersek" In-Reply-To: <20240115155948.136499-2-kraxel@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: pDtdiZzQoljjDnAoWaMJRro0x7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=xBPsnZE8; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 1/15/24 16:59, Gerd Hoffmann wrote: > This is needed to avoid bit operations being applied to signed integers. > > Suggested-by: László Érsek > Signed-off-by: Gerd Hoffmann > --- > OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h | 2 +- > OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h > index b7f5d208b236..455eafacc2cf 100644 > --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h > +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h > @@ -61,7 +61,7 @@ > #define P30_MAX_BUFFER_SIZE_IN_BYTES ((UINTN)128) > #define P30_MAX_BUFFER_SIZE_IN_WORDS (P30_MAX_BUFFER_SIZE_IN_BYTES/((UINTN)4)) > #define MAX_BUFFERED_PROG_ITERATIONS 10000000 > -#define BOUNDARY_OF_32_WORDS 0x7F > +#define BOUNDARY_OF_32_WORDS ((UINTN)0x7F) > > // CFI Addresses > #define P30_CFI_ADDR_QUERY_UNIQUE_QRY 0x10 I've made an effort to audit all current (= pre-patch) uses of BOUNDARY_OF_32_WORDS: the change looks safe. > diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c > index 1afd60ce66eb..7f4743b00399 100644 > --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c > +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c > @@ -581,7 +581,7 @@ NorFlashWriteSingleBlock ( > // contents, while checking whether the old version had any bits cleared > // that we want to set. In that case, we will need to erase the block first. > for (CurOffset = 0; CurOffset < *NumBytes; CurOffset++) { > - if (~OrigData[CurOffset] & Buffer[CurOffset]) { > + if (~(UINT32)OrigData[CurOffset] & (UINT32)Buffer[CurOffset]) { > goto DoErase; > } > The explicit cast for the RHS is not strictly necessary (the same would happen as a consequence of the cast being added to the LHS, through the usual arithmetic conversions), *but* it definitely doesn't hurt, and arguably improves readability. Reviewed-by: Laszlo Ersek (I'll probably look at the rest of the patches tomorrow.) Thanks! Laszlo -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113846): https://edk2.groups.io/g/devel/message/113846 Mute This Topic: https://groups.io/mt/103741662/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-