mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 09:21:26 +03:00
boot: add a way to indicate overflow in ALIGN_TO()
This commit is contained in:
parent
3fc0688d42
commit
88657f7575
@ -8,8 +8,20 @@
|
||||
|
||||
#define OFFSETOF(x,y) __builtin_offsetof(x,y)
|
||||
|
||||
#define UINTN_MAX (~(UINTN)0)
|
||||
#define INTN_MAX ((INTN)(UINTN_MAX>>1))
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX ((UINT32) -1)
|
||||
#endif
|
||||
#ifndef UINT64_MAX
|
||||
#define UINT64_MAX ((UINT64) -1)
|
||||
#endif
|
||||
|
||||
static inline UINTN ALIGN_TO(UINTN l, UINTN ali) {
|
||||
return ((l + ali - 1) & ~(ali - 1));
|
||||
if (l > UINTN_MAX - (ali - 1)) /* Overflow? */
|
||||
return UINTN_MAX;
|
||||
|
||||
return ((l + (ali - 1)) & ~(ali - 1));
|
||||
}
|
||||
|
||||
EFI_STATUS parse_boolean(const CHAR8 *v, BOOLEAN *b);
|
||||
@ -65,15 +77,6 @@ static inline void FileHandleClosep(EFI_FILE_HANDLE *handle) {
|
||||
&(const EFI_GUID) { 0x4a67b082, 0x0a4c, 0x41cf, { 0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f } }
|
||||
#define EFI_GLOBAL_GUID &(const EFI_GUID) EFI_GLOBAL_VARIABLE
|
||||
|
||||
#define UINTN_MAX (~(UINTN)0)
|
||||
#define INTN_MAX ((INTN)(UINTN_MAX>>1))
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX ((UINT32) -1)
|
||||
#endif
|
||||
#ifndef UINT64_MAX
|
||||
#define UINT64_MAX ((UINT64) -1)
|
||||
#endif
|
||||
|
||||
VOID log_error_stall(const CHAR16 *fmt, ...);
|
||||
EFI_STATUS log_oom(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user