Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1j6ZI8-0004It-DI for mharc-grub-devel@gnu.org; Tue, 25 Feb 2020 07:26:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55688) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6ZI5-0004Cf-71 for grub-devel@gnu.org; Tue, 25 Feb 2020 07:26:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6ZI4-0006kV-0k for grub-devel@gnu.org; Tue, 25 Feb 2020 07:26:21 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:40545 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6ZI3-0006kI-T0 for grub-devel@gnu.org; Tue, 25 Feb 2020 07:26:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582633579; 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=QgFI24oULjDUkUCyhgN6dy7SKvuk1EWg2asOsADYxdI=; b=TcCp41ndfY6WhG7hA/dbAEIOU9lARdyPKWSZpkv/UBU6SD12jzyJnEpO+opgmu6G+7eo1b +UE+LtSwY/U+gdyjno97wdgDYb5OrYsU8rOxLp5Lg4EI7rpffRyCXeqnIEBLn91+PMunET wYquU9SvKg2lQzUx5/VHrFSm19NJhy8= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-347-2DGlAZVOM-WBHR7dnFvyPw-1; Tue, 25 Feb 2020 07:26:17 -0500 X-MC-Unique: 2DGlAZVOM-WBHR7dnFvyPw-1 Received: by mail-wr1-f71.google.com with SMTP id s13so7193341wru.7 for ; Tue, 25 Feb 2020 04:26:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L4w588f8bih0hRTSyGujlyG80K28QG0ShMOicg/yoo0=; b=ZJAZedfmBM7tT+aXFO1ZLSzTY2OjUEQ/rSY27zWboIAlkeKWrDVTTn7Qi2zz6cqlRx 4mvYLaee2IlLPltnqZVVsHaCOjqyPAEgIbcgxc35EVdhOrkdCbB0Oi7W3uRHNea9ig+j TQGyTLo807vOXyMpqnpxiw3vOenIdLmeCB6td44jNzT7XImpIQ2VU2roC3PHtKfOi3Ri e8W7gxP0viWHqaWhy/xEuki0ZMOaDtE7TsxezhoLAD2tkyH1d0VHU+nDaEFqypaZx4I5 qlOJ6JzVU1SxAvYj2TBsX2LSJaKRSwbf97nVaHCrCCwvbuVLdrk8hVFngaoPV86uZNXN Unlg== X-Gm-Message-State: APjAAAWAldHF8T/D96LltxroorhJWIwInOXueLKq5W35jb3lfStLR60w mRwBO7mpO/5RsYk5ybS+fC4qWVKt8fMPvGp+b7BkJPKfkZjFCv/N1VZuTpAhJq0MbwC3Cjrw+xR azUyeVAxTl8A= X-Received: by 2002:a5d:638f:: with SMTP id p15mr72155511wru.402.1582633576310; Tue, 25 Feb 2020 04:26:16 -0800 (PST) X-Google-Smtp-Source: APXvYqytF3nxOcWhpUUjazs/94vbO07Czs50CCOGpbOYgFVoWbWzw8pl5ZYUWGXIfNSUES+I5JQzpg== X-Received: by 2002:a5d:638f:: with SMTP id p15mr72155498wru.402.1582633576085; Tue, 25 Feb 2020 04:26:16 -0800 (PST) Received: from minerva.redhat.com ([2a01:c50f:ab80:6700:527f:85b3:5615:ff0b]) by smtp.gmail.com with ESMTPSA id q6sm17251653wrf.67.2020.02.25.04.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 04:26:15 -0800 (PST) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Daniel Kiper , Peter Jones , Javier Martinez Canillas Subject: [PATCH 10/10] efi: Fix the type of grub_efi_status_t Date: Tue, 25 Feb 2020 13:25:53 +0100 Message-Id: <20200225122553.1120216-11-javierm@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200225122553.1120216-1-javierm@redhat.com> References: <20200225122553.1120216-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Feb 2020 12:26:22 -0000 From: Peter Jones Currently, in some builds with some checkers, we see: 1. grub-core/disk/efi/efidisk.c:601: error[shiftTooManyBitsSigned]: Shiftin= g signed 64-bit value by 63 bits is undefined behaviour This is because grub_efi_status_t is defined as grub_efi_intn_t, which is signed, and shifting into the sign bit is not defined behavior. UEFI fixed this in the spec in 2.3: 2.3 | Change the defined type of EFI_STATUS from INTN to UINTN | May 7, 200= 9 And the current EDK2 code has: MdePkg/Include/Base.h-// MdePkg/Include/Base.h-// Status codes common to all execution phases MdePkg/Include/Base.h-// MdePkg/Include/Base.h:typedef UINTN RETURN_STATUS; MdePkg/Include/Base.h- MdePkg/Include/Base.h-/** MdePkg/Include/Base.h- Produces a RETURN_STATUS code with the highest bit = set. MdePkg/Include/Base.h- MdePkg/Include/Base.h- @param StatusCode The status code value to conv= ert into a warning code. MdePkg/Include/Base.h- StatusCode must be in the ran= ge 0x00000000..0x7FFFFFFF. MdePkg/Include/Base.h- MdePkg/Include/Base.h- @return The value specified by StatusCode with the = highest bit set. MdePkg/Include/Base.h- MdePkg/Include/Base.h-**/ MdePkg/Include/Base.h-#define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)= (MAX_BIT | (StatusCode))) MdePkg/Include/Base.h- MdePkg/Include/Base.h-/** MdePkg/Include/Base.h- Produces a RETURN_STATUS code with the highest bit = clear. MdePkg/Include/Base.h- MdePkg/Include/Base.h- @param StatusCode The status code value to conv= ert into a warning code. MdePkg/Include/Base.h- StatusCode must be in the ran= ge 0x00000000..0x7FFFFFFF. MdePkg/Include/Base.h- MdePkg/Include/Base.h- @return The value specified by StatusCode with the = highest bit clear. MdePkg/Include/Base.h- MdePkg/Include/Base.h-**/ MdePkg/Include/Base.h-#define ENCODE_WARNING(StatusCode) ((RETURN_STATUS)= (StatusCode)) MdePkg/Include/Base.h- MdePkg/Include/Base.h-/** MdePkg/Include/Base.h- Returns TRUE if a specified RETURN_STATUS code is a= n error code. MdePkg/Include/Base.h- MdePkg/Include/Base.h- This function returns TRUE if StatusCode has the hi= gh bit set. Otherwise, FALSE is returned. MdePkg/Include/Base.h- MdePkg/Include/Base.h- @param StatusCode The status code value to eval= uate. MdePkg/Include/Base.h- MdePkg/Include/Base.h- @retval TRUE The high bit of StatusCode is= set. MdePkg/Include/Base.h- @retval FALSE The high bit of StatusCode is= clear. MdePkg/Include/Base.h- MdePkg/Include/Base.h-**/ MdePkg/Include/Base.h-#define RETURN_ERROR(StatusCode) (((INTN)(RETURN_= STATUS)(StatusCode)) < 0) ... Uefi/UefiBaseType.h:typedef RETURN_STATUS EFI_STATUS; This patch makes grub's implementation match the Edk2 declaration with rega= rds to the signedness of the type. Signed-off-by: Peter Jones Signed-off-by: Javier Martinez Canillas --- include/grub/efi/api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 57607438435..d6f4de17d63 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -531,7 +531,7 @@ typedef grub_uint64_t grub_efi_uint64_t; typedef grub_uint8_t grub_efi_char8_t; typedef grub_uint16_t grub_efi_char16_t; =20 -typedef grub_efi_intn_t grub_efi_status_t; +typedef grub_efi_uintn_t grub_efi_status_t; =20 #define GRUB_EFI_ERROR_CODE(value)=09\ ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (va= lue)) --=20 2.24.1