From c06635ea3f4b7b52054fe5d5b5e0cda3b594d2f5 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Mon, 21 Dec 2020 12:36:57 +0100 Subject: EmbeddedPkg/TimeBaseLib: remove useless truncation to 32-bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EfiTimeToEpoch() calls EfiGetEpochDays() internally, which (reasonably) returns a UINTN. But then EfiTimeToEpoch() truncates the EfiGetEpochDays() retval to UINT32 for no good reason, effectively restricting Time->Year under 2106. This truncation was pointed out with a valid warning (= build error) by VS2019. Allow EfiTimeToEpoch() to return / propagate a UINTN value. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Philippe Mathieu-Daudé Signed-off-by: Laszlo Ersek Message-Id: <20201221113657.6779-3-lersek@redhat.com> Acked-by: Ard Biesheuvel --- EmbeddedPkg/Include/Library/TimeBaseLib.h | 2 +- EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'EmbeddedPkg') diff --git a/EmbeddedPkg/Include/Library/TimeBaseLib.h b/EmbeddedPkg/Include/Library/TimeBaseLib.h index 3c2d3660c6..90853c3f4b 100644 --- a/EmbeddedPkg/Include/Library/TimeBaseLib.h +++ b/EmbeddedPkg/Include/Library/TimeBaseLib.h @@ -83,7 +83,7 @@ EpochToEfiTime ( /** Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) **/ -UINT32 +UINTN EFIAPI EfiTimeToEpoch ( IN EFI_TIME *Time diff --git a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c b/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c index 136ce8a51e..78fc7b6cd2 100644 --- a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c +++ b/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c @@ -99,14 +99,14 @@ EfiGetEpochDays ( /** Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) **/ -UINT32 +UINTN EFIAPI EfiTimeToEpoch ( IN EFI_TIME *Time ) { - UINT32 EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY - UINT32 EpochSeconds; + UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY + UINTN EpochSeconds; EpochDays = EfiGetEpochDays (Time); -- cgit v1.2.3