Make sure MIN() and MAX() are always defined.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2020-12-10 11:24:09 -05:00 committed by Javier Martinez Canillas
parent 8537e0555c
commit 9c64b6278c
4 changed files with 6 additions and 8 deletions

View File

@ -149,5 +149,8 @@
#define ALIGN_DOWN(x, a) __ALIGN((x) - ((a) - 1), (a))
#endif
#define MIN(a, b) ({(a) < (b) ? (a) : (b);})
#define MAX(a, b) ({(a) <= (b) ? (b) : (a);})
#endif /* !COMPILER_H_ */
// vim:fenc=utf-8:tw=75:et

View File

@ -213,7 +213,7 @@ console_print_box_at(CHAR16 *str_arr[], int highlight,
if (col < 0)
col = 0;
CopyMem(Line + col + 1, s, min(len, size_cols - 2)*2);
CopyMem(Line + col + 1, s, MIN(len, size_cols - 2)*2);
}
if (line >= 0 && line == highlight)
co->SetAttribute(co, EFI_LIGHTGRAY |

4
mok.c
View File

@ -253,7 +253,7 @@ mirror_one_esl(CHAR16 *name, EFI_GUID *guid, UINT32 attrs,
SIZE_T howmany, varsz = 0, esdsz;
UINT8 *var, *data;
howmany = min((maxsz - sizeof(*esl)) / esl->SignatureSize,
howmany = MIN((maxsz - sizeof(*esl)) / esl->SignatureSize,
(esl->SignatureListSize - sizeof(*esl)) / esl->SignatureSize);
if (howmany < 1) {
return EFI_BUFFER_TOO_SMALL;
@ -411,7 +411,7 @@ mirror_mok_db(CHAR16 *name, CHAR8 *name8, EFI_GUID *guid, UINT32 attrs,
SIZE_T howmany;
UINTN adj = 0;
howmany = min((max_var_sz - sizeof(*esl)) / esl->SignatureSize,
howmany = MIN((max_var_sz - sizeof(*esl)) / esl->SignatureSize,
(esl->SignatureListSize - sizeof(*esl)) / esl->SignatureSize);
if (!only_first && i == 0 && howmany >= 1) {
adj = howmany * esl->SignatureSize;

5
shim.h
View File

@ -35,8 +35,6 @@
#define nonnull(...) __attribute__((__nonnull__(__VA_ARGS__)))
#define min(a, b) ({(a) < (b) ? (a) : (b);})
#ifdef __x86_64__
#ifndef DEFAULT_LOADER
#define DEFAULT_LOADER L"\\grubx64.efi"
@ -233,7 +231,4 @@ verify_buffer (char *data, int datasize,
#define LogError(fmt, ...) \
LogError_(__FILE__, __LINE__ - 1, __func__, fmt, ##__VA_ARGS__)
#define MIN(a, b) (((a) <= (b))?(a):(b))
#define MAX(a, b) (((a) <= (b))?(b):(a))
#endif /* SHIM_H_ */