Commit b3efa77
committed
EmbeddedPkg/VirtualRealTimeClockLib: Fix VS2022 type conversion warnings
Fix type conversion warnings (C4244) in VirtualRealTimeClockLib that
prevent it from building with Visual Studio 2022 when the /WX flag
(treat warnings as errors) is enabled.
Changes made:
EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
- Add (UINTN) casts for DivU64x64Remainder return values in LibGetTime()
- Add (UINTN) casts for DivU64x64Remainder return values in LibSetTime()
Rationale:
- DivU64x64Remainder returns UINT64 values
- On IA32 architecture, UINTN is 32-bit while the return value is 64-bit
- Explicit casts are required to handle the 64-bit to 32-bit conversion
on IA32 without data loss warnings
- The casts are safe because the values represent elapsed seconds since
platform reset, which will not overflow 32-bit values in practice
Tested on:
- Windows 11 with VS2022 (X64 and IA32)
- Ubuntu with GCC5 (X64)
Addresses: #11737
Signed-off-by: Gary Beihl <[email protected]>1 parent d18fae3 commit b3efa77
File tree
1 file changed
+3
-3
lines changed- EmbeddedPkg/Library/VirtualRealTimeClockLib
1 file changed
+3
-3
lines changedLines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
275 | | - | |
| 274 | + | |
| 275 | + | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| |||
0 commit comments