From 122dbd92c96199e417270a66925c38ac0d03ff4e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 1 Jun 2021 17:58:56 +0900 Subject: [PATCH 1/9] string-util: trivial optimizations for strverscmp_improved() --- src/fundamental/string-util-fundamental.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fundamental/string-util-fundamental.c b/src/fundamental/string-util-fundamental.c index 9f14597fef..383e390577 100644 --- a/src/fundamental/string-util-fundamental.c +++ b/src/fundamental/string-util-fundamental.c @@ -152,7 +152,7 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) { * Note that except for '~' prefixed segments, a string has more segments is newer. * So, this check must be after the '~' check. */ if (*a == '\0' || *b == '\0') - return strcmp(a, b); + return CMP(*a, *b); /* Handle '-', which separates version and release, e.g 123.4-3.1.fc33.x86_64 */ if (*a == '-' || *b == '-') { @@ -194,9 +194,9 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) { /* Find the leading numeric segments. One may be an empty string. So, * numeric segments are always newer than alpha segments. */ - for (aa = a; *aa != '\0' && isdigit(*aa); aa++) + for (aa = a; isdigit(*aa); aa++) ; - for (bb = b; *bb != '\0' && isdigit(*bb); bb++) + for (bb = b; isdigit(*bb); bb++) ; /* To compare numeric segments without parsing their values, first compare the @@ -211,9 +211,9 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) { return r; } else { /* Find the leading non-numeric segments. */ - for (aa = a; *aa != '\0' && is_alpha(*aa); aa++) + for (aa = a; is_alpha(*aa); aa++) ; - for (bb = b; *bb != '\0' && is_alpha(*bb); bb++) + for (bb = b; is_alpha(*bb); bb++) ; /* Note that the segments are usually not NUL-terminated. */ From 959ab90bbc08855ad5824efecbc03d37b3f9c982 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Jun 2021 15:36:26 +0900 Subject: [PATCH 2/9] efi: do not use _STRING_ARCH_unaligned macro It is already removed from glibc. See, https://sourceware.org/git/?p=glibc.git;a=commit;h=16396c41deab45f715ffd813280d9d685b3b281e https://sourceware.org/git/?p=glibc.git;a=commit;h=09a596cc2cf4e0f9f8e9f3bba4b1a97efcb13bcb --- src/boot/efi/sha256.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/boot/efi/sha256.c b/src/boot/efi/sha256.c index 774f0eeb6c..2108ea29c7 100644 --- a/src/boot/efi/sha256.c +++ b/src/boot/efi/sha256.c @@ -143,9 +143,12 @@ void sha256_process_bytes(const void *buffer, UINTN len, struct sha256_ctx *ctx) /* Process available complete blocks. */ if (len >= 64) { -#if !_STRING_ARCH_unaligned -/* To check alignment gcc has an appropriate operator. Other - compilers don't. */ + +/* The condition below is from glibc's string/string-inline.c. + * See definition of _STRING_INLINE_unaligned. */ +#if !defined(__mc68020__) && !defined(__s390__) && !defined(__i386__) + +/* To check alignment gcc has an appropriate operator. Other compilers don't. */ # if __GNUC__ >= 2 # define UNALIGNED_P(p) (((UINTN) p) % __alignof__ (UINT32) != 0) # else From 72dc626b3d6905b105ae61ca2c60f51a6f74070e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Jun 2021 15:38:29 +0900 Subject: [PATCH 3/9] efi: include endian.h to handle endian correctly The macro __BYTE_ORDER__ is defined in endian.h. --- src/boot/efi/sha256.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/boot/efi/sha256.h b/src/boot/efi/sha256.h index 464be59c25..3a43601e73 100644 --- a/src/boot/efi/sha256.h +++ b/src/boot/efi/sha256.h @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include + #include #include From ef53d52b01967d1b126ca629bb74fd1b633dcf0c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Jun 2021 15:40:56 +0900 Subject: [PATCH 4/9] efi: add const qualifier to string utils --- src/boot/efi/util.c | 10 +++++----- src/boot/efi/util.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c index 0061e03eba..c6aa7954bc 100644 --- a/src/boot/efi/util.c +++ b/src/boot/efi/util.c @@ -245,7 +245,7 @@ VOID efivar_set_time_usec(const EFI_GUID *vendor, CHAR16 *name, UINT64 usec) { efivar_set(vendor, name, str, 0); } -static INTN utf8_to_16(CHAR8 *stra, CHAR16 *c) { +static INTN utf8_to_16(const CHAR8 *stra, CHAR16 *c) { CHAR16 unichar; UINTN len; @@ -296,7 +296,7 @@ static INTN utf8_to_16(CHAR8 *stra, CHAR16 *c) { return len; } -CHAR16 *stra_to_str(CHAR8 *stra) { +CHAR16 *stra_to_str(const CHAR8 *stra) { UINTN strlen; UINTN len; UINTN i; @@ -324,7 +324,7 @@ CHAR16 *stra_to_str(CHAR8 *stra) { return str; } -CHAR16 *stra_to_path(CHAR8 *stra) { +CHAR16 *stra_to_path(const CHAR8 *stra) { CHAR16 *str; UINTN strlen; UINTN len; @@ -361,10 +361,10 @@ CHAR16 *stra_to_path(CHAR8 *stra) { return str; } -CHAR8 *strchra(CHAR8 *s, CHAR8 c) { +CHAR8 *strchra(const CHAR8 *s, CHAR8 c) { do { if (*s == c) - return s; + return (CHAR8*) s; } while (*s++); return NULL; } diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index f3c97186e8..fc7377c0f7 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -32,9 +32,9 @@ EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, UINT EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT64 *ret); EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const CHAR16 *name, BOOLEAN *ret); -CHAR8 *strchra(CHAR8 *s, CHAR8 c); -CHAR16 *stra_to_path(CHAR8 *stra); -CHAR16 *stra_to_str(CHAR8 *stra); +CHAR8 *strchra(const CHAR8 *s, CHAR8 c); +CHAR16 *stra_to_path(const CHAR8 *stra); +CHAR16 *stra_to_str(const CHAR8 *stra); EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN size, CHAR8 **content, UINTN *content_size); From edad24c61e0b0a8a68d5feee735161ffd1863297 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Jun 2021 15:41:39 +0900 Subject: [PATCH 5/9] efi: add const qualifier to EFI variable handling functions --- src/boot/efi/util.c | 8 ++++---- src/boot/efi/util.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c index c6aa7954bc..6f4e5933d3 100644 --- a/src/boot/efi/util.c +++ b/src/boot/efi/util.c @@ -84,14 +84,14 @@ EFI_STATUS efivar_set(const EFI_GUID *vendor, const CHAR16 *name, const CHAR16 * return efivar_set_raw(vendor, name, value, value ? (StrLen(value) + 1) * sizeof(CHAR16) : 0, flags); } -EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, CHAR16 *name, UINTN i, UINT32 flags) { +EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UINTN i, UINT32 flags) { CHAR16 str[32]; SPrint(str, 32, L"%u", i); return efivar_set(vendor, name, str, flags); } -EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, CHAR16 *name, UINT32 value, UINT32 flags) { +EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, UINT32 value, UINT32 flags) { UINT8 buf[4]; buf[0] = (UINT8)(value >> 0U & 0xFF); @@ -102,7 +102,7 @@ EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, CHAR16 *name, UINT32 val return efivar_set_raw(vendor, name, buf, sizeof(buf), flags); } -EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, CHAR16 *name, UINT64 value, UINT32 flags) { +EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT64 value, UINT32 flags) { UINT8 buf[8]; buf[0] = (UINT8)(value >> 0U & 0xFF); @@ -233,7 +233,7 @@ EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const CHAR16 *name, BOO return err; } -VOID efivar_set_time_usec(const EFI_GUID *vendor, CHAR16 *name, UINT64 usec) { +VOID efivar_set_time_usec(const EFI_GUID *vendor, const CHAR16 *name, UINT64 usec) { CHAR16 str[32]; if (usec == 0) diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index fc7377c0f7..1a42b01033 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -20,10 +20,10 @@ UINT64 time_usec(void); EFI_STATUS efivar_set(const EFI_GUID *vendor, const CHAR16 *name, const CHAR16 *value, UINT32 flags); EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const CHAR16 *name, const VOID *buf, UINTN size, UINT32 flags); -EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, CHAR16 *name, UINTN i, UINT32 flags); -EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, CHAR16 *NAME, UINT32 value, UINT32 flags); -EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, CHAR16 *name, UINT64 value, UINT32 flags); -VOID efivar_set_time_usec(const EFI_GUID *vendor, CHAR16 *name, UINT64 usec); +EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UINTN i, UINT32 flags); +EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, const CHAR16 *NAME, UINT32 value, UINT32 flags); +EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT64 value, UINT32 flags); +VOID efivar_set_time_usec(const EFI_GUID *vendor, const CHAR16 *name, UINT64 usec); EFI_STATUS efivar_get(const EFI_GUID *vendor, const CHAR16 *name, CHAR16 **value); EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const CHAR16 *name, CHAR8 **buffer, UINTN *size); From cfb7fa289d5d423582c0b73cd42a637d926db874 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Jun 2021 15:43:21 +0900 Subject: [PATCH 6/9] efi: drop const qualifiers from arguments in uefi_call_wrapper() --- src/boot/efi/boot.c | 12 ++++++------ src/boot/efi/random-seed.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 24efe5de1d..84af147856 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -521,7 +521,7 @@ static BOOLEAN menu_run( uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK); /* draw a single character to make ClearScreen work on some firmware */ - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L" "); + uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*) L" "); if (config->console_mode_change != CONSOLE_MODE_KEEP) { err = console_set_mode(&config->console_mode, config->console_mode_change); @@ -618,7 +618,7 @@ static BOOLEAN menu_run( uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[i]); if ((INTN)i == config->idx_default_efivar) { uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, x_start-3, y_start + i - idx_first); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"=>"); + uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*) L"=>"); } } refresh = FALSE; @@ -628,7 +628,7 @@ static BOOLEAN menu_run( uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[idx_highlight_prev]); if ((INTN)idx_highlight_prev == config->idx_default_efivar) { uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, x_start-3, y_start + idx_highlight_prev - idx_first); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"=>"); + uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*) L"=>"); } uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_start + idx_highlight - idx_first); @@ -636,7 +636,7 @@ static BOOLEAN menu_run( uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[idx_highlight]); if ((INTN)idx_highlight == config->idx_default_efivar) { uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, x_start-3, y_start + idx_highlight - idx_first); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"=>"); + uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*) L"=>"); } highlight = FALSE; } @@ -1437,7 +1437,7 @@ static VOID config_load_entries( EFI_FILE_HANDLE entries_dir; EFI_STATUS err; - err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &entries_dir, L"\\loader\\entries", EFI_FILE_MODE_READ, 0ULL); + err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &entries_dir, (CHAR16*) L"\\loader\\entries", EFI_FILE_MODE_READ, 0ULL); if (!EFI_ERROR(err)) { for (;;) { CHAR16 buf[256]; @@ -1824,7 +1824,7 @@ static VOID config_entry_add_linux( EFI_STATUS err; ConfigEntry *entry; - err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &linux_dir, L"\\EFI\\Linux", EFI_FILE_MODE_READ, 0ULL); + err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &linux_dir, (CHAR16*) L"\\EFI\\Linux", EFI_FILE_MODE_READ, 0ULL); if (EFI_ERROR(err)) return; diff --git a/src/boot/efi/random-seed.c b/src/boot/efi/random-seed.c index 6de520c0c3..ff364695f3 100644 --- a/src/boot/efi/random-seed.c +++ b/src/boot/efi/random-seed.c @@ -243,7 +243,7 @@ EFI_STATUS process_random_seed(EFI_FILE *root_dir, RandomSeedMode mode) { if (mode != RANDOM_SEED_ALWAYS && EFI_ERROR(err)) return err; - err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, L"\\loader\\random-seed", EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0ULL); + err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, (CHAR16*) L"\\loader\\random-seed", EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0ULL); if (EFI_ERROR(err)) { if (err != EFI_NOT_FOUND) Print(L"Failed to open random seed file: %r\n", err); From ca474d5114cf57580fba13ea1cf0528554f57266 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Jun 2021 15:45:47 +0900 Subject: [PATCH 7/9] efi: constify several arguments of functions which handle loader entries --- src/boot/efi/boot.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 84af147856..3249171ec1 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -91,7 +91,7 @@ static VOID cursor_right( } static BOOLEAN line_edit( - CHAR16 *line_in, + const CHAR16 *line_in, CHAR16 **line_out, UINTN x_max, UINTN y_pos) { @@ -916,14 +916,13 @@ static VOID config_entry_free(ConfigEntry *entry) { static CHAR8 *line_get_key_value( CHAR8 *content, - CHAR8 *sep, + const CHAR8 *sep, UINTN *pos, CHAR8 **key_ret, CHAR8 **value_ret) { - CHAR8 *line; + CHAR8 *line, *value; UINTN linelen; - CHAR8 *value; skip: line = content + *pos; @@ -1073,9 +1072,9 @@ static VOID config_defaults_load_from_file(Config *config, CHAR8 *content) { static VOID config_entry_parse_tries( ConfigEntry *entry, - CHAR16 *path, - CHAR16 *file, - CHAR16 *suffix) { + const CHAR16 *path, + const CHAR16 *file, + const CHAR16 *suffix) { UINTN left = UINTN_MAX, done = UINTN_MAX, factor = 1, i, next_left, next_done; _cleanup_freepool_ CHAR16 *prefix = NULL; @@ -1259,10 +1258,10 @@ static VOID config_entry_add_from_file( Config *config, EFI_HANDLE *device, EFI_FILE *root_dir, - CHAR16 *path, - CHAR16 *file, + const CHAR16 *path, + const CHAR16 *file, CHAR8 *content, - CHAR16 *loaded_image_path) { + const CHAR16 *loaded_image_path) { ConfigEntry *entry; CHAR8 *line; @@ -1689,8 +1688,8 @@ static VOID config_title_generate(Config *config) { static BOOLEAN config_entry_add_call( Config *config, - CHAR16 *id, - CHAR16 *title, + const CHAR16 *id, + const CHAR16 *title, EFI_STATUS (*call)(VOID)) { ConfigEntry *entry; @@ -1713,11 +1712,11 @@ static ConfigEntry *config_entry_add_loader( Config *config, EFI_HANDLE *device, enum loader_type type, - CHAR16 *id, + const CHAR16 *id, CHAR16 key, - CHAR16 *title, - CHAR16 *loader, - CHAR16 *version) { + const CHAR16 *title, + const CHAR16 *loader, + const CHAR16 *version) { ConfigEntry *entry; @@ -1744,11 +1743,11 @@ static BOOLEAN config_entry_add_loader_auto( Config *config, EFI_HANDLE *device, EFI_FILE *root_dir, - CHAR16 *loaded_image_path, - CHAR16 *id, + const CHAR16 *loaded_image_path, + const CHAR16 *id, CHAR16 key, - CHAR16 *title, - CHAR16 *loader) { + const CHAR16 *title, + const CHAR16 *loader) { EFI_FILE_HANDLE handle; ConfigEntry *entry; @@ -1774,7 +1773,7 @@ static BOOLEAN config_entry_add_loader_auto( } /* check existence */ - err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, loader, EFI_FILE_MODE_READ, 0ULL); + err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, (CHAR16*) loader, EFI_FILE_MODE_READ, 0ULL); if (EFI_ERROR(err)) return FALSE; uefi_call_wrapper(handle->Close, 1, handle); From 65267363978dbb298eb4ba9b628d028c969fa616 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Jun 2021 15:49:44 +0900 Subject: [PATCH 8/9] meson: enable more warnings when building efi binary --- meson.build | 19 +++++++++++-------- src/boot/efi/meson.build | 32 ++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/meson.build b/meson.build index 65d0a0f6ea..696d84951c 100644 --- a/meson.build +++ b/meson.build @@ -325,7 +325,7 @@ basic_disabled_warnings = [ '-Wno-format-signedness', ] -possible_cc_flags = [ +possible_common_cc_flags = [ '-Werror=undef', '-Wlogical-op', '-Wmissing-include-dirs', @@ -334,9 +334,7 @@ possible_cc_flags = [ '-Winit-self', '-Wfloat-equal', '-Wsuggest-attribute=noreturn', - '-Werror=missing-prototypes', '-Werror=implicit-function-declaration', - '-Werror=missing-declarations', '-Werror=return-type', '-Werror=incompatible-pointer-types', '-Werror=format=2', @@ -363,8 +361,6 @@ possible_cc_flags = [ '-fdiagnostics-show-option', '-fno-strict-aliasing', '-fvisibility=hidden', - '-fstack-protector', - '-fstack-protector-strong', '--param=ssp-buffer-size=4', ] @@ -374,7 +370,7 @@ possible_cc_flags = [ # busywork. See https://github.com/systemd/systemd/pull/19226. if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or cc.version().version_compare('<10')) - possible_cc_flags += '-Wno-maybe-uninitialized' + possible_common_cc_flags += '-Wno-maybe-uninitialized' endif # --as-needed and --no-undefined are provided by meson by default, @@ -386,14 +382,14 @@ possible_link_flags = [ ] if cc.get_id() == 'clang' - possible_cc_flags += [ + possible_common_cc_flags += [ '-Wno-typedef-redefinition', '-Wno-gnu-variable-sized-type-not-at-end', ] endif if get_option('buildtype') != 'debug' - possible_cc_flags += [ + possible_common_cc_flags += [ '-ffunction-sections', '-fdata-sections', ] @@ -401,6 +397,13 @@ if get_option('buildtype') != 'debug' possible_link_flags += '-Wl,--gc-sections' endif +possible_cc_flags = possible_common_cc_flags + [ + '-Werror=missing-declarations', + '-Werror=missing-prototypes', + '-fstack-protector', + '-fstack-protector-strong', +] + add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c') add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c') add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c') diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build index ad549fb65a..06b2fe5d81 100644 --- a/src/boot/efi/meson.build +++ b/src/boot/efi/meson.build @@ -175,23 +175,27 @@ if have_gnu_efi endif if have_gnu_efi - compile_args = ['-Wall', - '-Wextra', - '-std=gnu99', - '-nostdlib', + compile_args = cc.get_supported_arguments( + basic_disabled_warnings + + possible_common_cc_flags + [ + '-ffreestanding', + '-fno-stack-protector', '-fpic', '-fshort-wchar', - '-ffreestanding', - '-fno-strict-aliasing', - '-fno-stack-protector', + '-Wall', + '-Wextra', '-Wsign-compare', - '-Wno-missing-field-initializers', - '-isystem', efi_incdir, - '-isystem', join_paths(efi_incdir, gnu_efi_path_arch), - '-I', fundamental_path, - '-DSD_BOOT', - '-include', efi_config_h, - '-include', version_h] + ] + ) + [ + '-nostdlib', + '-std=gnu99', + '-isystem', efi_incdir, + '-isystem', join_paths(efi_incdir, gnu_efi_path_arch), + '-I', fundamental_path, + '-DSD_BOOT', + '-include', efi_config_h, + '-include', version_h, + ] if efi_arch == 'x86_64' compile_args += ['-mno-red-zone', '-mno-sse', From 505ab9dda2147375a72cd1593c8c483a9c516faa Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Jun 2021 15:53:29 +0900 Subject: [PATCH 9/9] meson: sort compiler flags --- meson.build | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/meson.build b/meson.build index 696d84951c..8a83a4e268 100644 --- a/meson.build +++ b/meson.build @@ -319,38 +319,38 @@ endif # Those generate many false positives, and we do not want to change the code to # avoid them. basic_disabled_warnings = [ - '-Wno-unused-parameter', - '-Wno-missing-field-initializers', - '-Wno-unused-result', '-Wno-format-signedness', + '-Wno-missing-field-initializers', + '-Wno-unused-parameter', + '-Wno-unused-result', ] possible_common_cc_flags = [ - '-Werror=undef', - '-Wlogical-op', - '-Wmissing-include-dirs', - '-Wold-style-definition', - '-Wpointer-arith', - '-Winit-self', - '-Wfloat-equal', - '-Wsuggest-attribute=noreturn', - '-Werror=implicit-function-declaration', - '-Werror=return-type', - '-Werror=incompatible-pointer-types', - '-Werror=format=2', - '-Wstrict-prototypes', - '-Wredundant-decls', - '-Wmissing-noreturn', - '-Wimplicit-fallthrough=5', - '-Wshadow', + '-Wdate-time', '-Wendif-labels', - '-Wstrict-aliasing=2', - '-Wwrite-strings', + '-Werror=format=2', + '-Werror=implicit-function-declaration', + '-Werror=incompatible-pointer-types', '-Werror=overflow', + '-Werror=return-type', '-Werror=shift-count-overflow', '-Werror=shift-overflow=2', - '-Wdate-time', + '-Werror=undef', + '-Wfloat-equal', + '-Wimplicit-fallthrough=5', + '-Winit-self', + '-Wlogical-op', + '-Wmissing-include-dirs', + '-Wmissing-noreturn', '-Wnested-externs', + '-Wold-style-definition', + '-Wpointer-arith', + '-Wredundant-decls', + '-Wshadow', + '-Wstrict-aliasing=2', + '-Wstrict-prototypes', + '-Wsuggest-attribute=noreturn', + '-Wwrite-strings', # negative arguments are correctly detected starting with meson 0.46. '-Wno-error=#warnings', # clang