Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[edk2-devel] [PATCH 0/2] EmbeddedPkg/TimeBaseLib: remove useless truncation to 32-bit -- push #1254

Merged
merged 2 commits into from
Dec 21, 2020

Conversation

lersek
Copy link
Member

@lersek lersek commented Dec 21, 2020

msgid 20201221113657.6779-1-lersek@redhat.com
https://edk2.groups.io/g/devel/message/69313
https://www.redhat.com/archives/edk2-devel-archive/2020-December/msg01218.html

Repo:   https://pagure.io/lersek/edk2.git
Branch: timebaselib_uintn

Through the virtio-fs driver, EmbeddedPkg/TimeBaseLib got exposed to
VS2019 for the first time. VS2019 flagged an arguably unintended,
implicit UINTN->UINT32 conversion in EfiTimeToEpoch(); let's remedy
that.

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>

Thanks!
Laszlo

Laszlo Ersek (2):
  ArmPlatformPkg/PL031RealTimeClockLib: cast EfiTimeToEpoch() val. to
    UINT32
  EmbeddedPkg/TimeBaseLib: remove useless truncation to 32-bit

 EmbeddedPkg/Include/Library/TimeBaseLib.h                            | 2 +-
 ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c | 2 +-
 EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c                        | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

@lersek lersek added the push Auto push patch series in PR if all checks pass label Dec 21, 2020
…INT32

In preparation for changing EfiTimeToEpoch()'s return type to UINTN, cast
EfiTimeToEpoch()'s retval to UINT32 explicitly, in LibSetTime().

Currently, this is a no-op, and even after widening the retval, it will
make no difference, as LibSetTime() explicitly restricts Time->Year under
2106, given that "the PL031 is a 32-bit counter counting seconds". The
patch is made for preventing compiler warnings.

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20201221113657.6779-2-lersek@redhat.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
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 <ard.biesheuvel@arm.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20201221113657.6779-3-lersek@redhat.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
@mergify mergify bot merged commit c06635e into tianocore:master Dec 21, 2020
@lersek lersek deleted the timebaselib_uintn_push branch December 21, 2020 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
push Auto push patch series in PR if all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant