mirror of
https://github.com/systemd/systemd
synced 2024-10-15 12:34:37 +00:00
Merge pull request #19783 from yuwata/efi-build-options
efi: constify several functions and enable more warnings
This commit is contained in:
commit
c17b4f4b0e
65
meson.build
65
meson.build
|
@ -319,40 +319,38 @@ endif
|
||||||
# Those generate many false positives, and we do not want to change the code to
|
# Those generate many false positives, and we do not want to change the code to
|
||||||
# avoid them.
|
# avoid them.
|
||||||
basic_disabled_warnings = [
|
basic_disabled_warnings = [
|
||||||
'-Wno-unused-parameter',
|
|
||||||
'-Wno-missing-field-initializers',
|
|
||||||
'-Wno-unused-result',
|
|
||||||
'-Wno-format-signedness',
|
'-Wno-format-signedness',
|
||||||
|
'-Wno-missing-field-initializers',
|
||||||
|
'-Wno-unused-parameter',
|
||||||
|
'-Wno-unused-result',
|
||||||
]
|
]
|
||||||
|
|
||||||
possible_cc_flags = [
|
possible_common_cc_flags = [
|
||||||
'-Werror=undef',
|
'-Wdate-time',
|
||||||
'-Wlogical-op',
|
|
||||||
'-Wmissing-include-dirs',
|
|
||||||
'-Wold-style-definition',
|
|
||||||
'-Wpointer-arith',
|
|
||||||
'-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',
|
|
||||||
'-Wstrict-prototypes',
|
|
||||||
'-Wredundant-decls',
|
|
||||||
'-Wmissing-noreturn',
|
|
||||||
'-Wimplicit-fallthrough=5',
|
|
||||||
'-Wshadow',
|
|
||||||
'-Wendif-labels',
|
'-Wendif-labels',
|
||||||
'-Wstrict-aliasing=2',
|
'-Werror=format=2',
|
||||||
'-Wwrite-strings',
|
'-Werror=implicit-function-declaration',
|
||||||
|
'-Werror=incompatible-pointer-types',
|
||||||
'-Werror=overflow',
|
'-Werror=overflow',
|
||||||
|
'-Werror=return-type',
|
||||||
'-Werror=shift-count-overflow',
|
'-Werror=shift-count-overflow',
|
||||||
'-Werror=shift-overflow=2',
|
'-Werror=shift-overflow=2',
|
||||||
'-Wdate-time',
|
'-Werror=undef',
|
||||||
|
'-Wfloat-equal',
|
||||||
|
'-Wimplicit-fallthrough=5',
|
||||||
|
'-Winit-self',
|
||||||
|
'-Wlogical-op',
|
||||||
|
'-Wmissing-include-dirs',
|
||||||
|
'-Wmissing-noreturn',
|
||||||
'-Wnested-externs',
|
'-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.
|
# negative arguments are correctly detected starting with meson 0.46.
|
||||||
'-Wno-error=#warnings', # clang
|
'-Wno-error=#warnings', # clang
|
||||||
|
@ -363,8 +361,6 @@ possible_cc_flags = [
|
||||||
'-fdiagnostics-show-option',
|
'-fdiagnostics-show-option',
|
||||||
'-fno-strict-aliasing',
|
'-fno-strict-aliasing',
|
||||||
'-fvisibility=hidden',
|
'-fvisibility=hidden',
|
||||||
'-fstack-protector',
|
|
||||||
'-fstack-protector-strong',
|
|
||||||
'--param=ssp-buffer-size=4',
|
'--param=ssp-buffer-size=4',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -374,7 +370,7 @@ possible_cc_flags = [
|
||||||
# busywork. See https://github.com/systemd/systemd/pull/19226.
|
# busywork. See https://github.com/systemd/systemd/pull/19226.
|
||||||
if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
|
if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
|
||||||
cc.version().version_compare('<10'))
|
cc.version().version_compare('<10'))
|
||||||
possible_cc_flags += '-Wno-maybe-uninitialized'
|
possible_common_cc_flags += '-Wno-maybe-uninitialized'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# --as-needed and --no-undefined are provided by meson by default,
|
# --as-needed and --no-undefined are provided by meson by default,
|
||||||
|
@ -386,14 +382,14 @@ possible_link_flags = [
|
||||||
]
|
]
|
||||||
|
|
||||||
if cc.get_id() == 'clang'
|
if cc.get_id() == 'clang'
|
||||||
possible_cc_flags += [
|
possible_common_cc_flags += [
|
||||||
'-Wno-typedef-redefinition',
|
'-Wno-typedef-redefinition',
|
||||||
'-Wno-gnu-variable-sized-type-not-at-end',
|
'-Wno-gnu-variable-sized-type-not-at-end',
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('buildtype') != 'debug'
|
if get_option('buildtype') != 'debug'
|
||||||
possible_cc_flags += [
|
possible_common_cc_flags += [
|
||||||
'-ffunction-sections',
|
'-ffunction-sections',
|
||||||
'-fdata-sections',
|
'-fdata-sections',
|
||||||
]
|
]
|
||||||
|
@ -401,6 +397,13 @@ if get_option('buildtype') != 'debug'
|
||||||
possible_link_flags += '-Wl,--gc-sections'
|
possible_link_flags += '-Wl,--gc-sections'
|
||||||
endif
|
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(basic_disabled_warnings), language : 'c')
|
||||||
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), 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')
|
add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
|
||||||
|
|
|
@ -91,7 +91,7 @@ static VOID cursor_right(
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOLEAN line_edit(
|
static BOOLEAN line_edit(
|
||||||
CHAR16 *line_in,
|
const CHAR16 *line_in,
|
||||||
CHAR16 **line_out,
|
CHAR16 **line_out,
|
||||||
UINTN x_max,
|
UINTN x_max,
|
||||||
UINTN y_pos) {
|
UINTN y_pos) {
|
||||||
|
@ -521,7 +521,7 @@ static BOOLEAN menu_run(
|
||||||
uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK);
|
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 */
|
/* 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) {
|
if (config->console_mode_change != CONSOLE_MODE_KEEP) {
|
||||||
err = console_set_mode(&config->console_mode, config->console_mode_change);
|
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]);
|
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[i]);
|
||||||
if ((INTN)i == config->idx_default_efivar) {
|
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->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;
|
refresh = FALSE;
|
||||||
|
@ -628,7 +628,7 @@ static BOOLEAN menu_run(
|
||||||
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[idx_highlight_prev]);
|
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[idx_highlight_prev]);
|
||||||
if ((INTN)idx_highlight_prev == config->idx_default_efivar) {
|
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->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);
|
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]);
|
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[idx_highlight]);
|
||||||
if ((INTN)idx_highlight == config->idx_default_efivar) {
|
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->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;
|
highlight = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -916,14 +916,13 @@ static VOID config_entry_free(ConfigEntry *entry) {
|
||||||
|
|
||||||
static CHAR8 *line_get_key_value(
|
static CHAR8 *line_get_key_value(
|
||||||
CHAR8 *content,
|
CHAR8 *content,
|
||||||
CHAR8 *sep,
|
const CHAR8 *sep,
|
||||||
UINTN *pos,
|
UINTN *pos,
|
||||||
CHAR8 **key_ret,
|
CHAR8 **key_ret,
|
||||||
CHAR8 **value_ret) {
|
CHAR8 **value_ret) {
|
||||||
|
|
||||||
CHAR8 *line;
|
CHAR8 *line, *value;
|
||||||
UINTN linelen;
|
UINTN linelen;
|
||||||
CHAR8 *value;
|
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
line = content + *pos;
|
line = content + *pos;
|
||||||
|
@ -1073,9 +1072,9 @@ static VOID config_defaults_load_from_file(Config *config, CHAR8 *content) {
|
||||||
|
|
||||||
static VOID config_entry_parse_tries(
|
static VOID config_entry_parse_tries(
|
||||||
ConfigEntry *entry,
|
ConfigEntry *entry,
|
||||||
CHAR16 *path,
|
const CHAR16 *path,
|
||||||
CHAR16 *file,
|
const CHAR16 *file,
|
||||||
CHAR16 *suffix) {
|
const CHAR16 *suffix) {
|
||||||
|
|
||||||
UINTN left = UINTN_MAX, done = UINTN_MAX, factor = 1, i, next_left, next_done;
|
UINTN left = UINTN_MAX, done = UINTN_MAX, factor = 1, i, next_left, next_done;
|
||||||
_cleanup_freepool_ CHAR16 *prefix = NULL;
|
_cleanup_freepool_ CHAR16 *prefix = NULL;
|
||||||
|
@ -1259,10 +1258,10 @@ static VOID config_entry_add_from_file(
|
||||||
Config *config,
|
Config *config,
|
||||||
EFI_HANDLE *device,
|
EFI_HANDLE *device,
|
||||||
EFI_FILE *root_dir,
|
EFI_FILE *root_dir,
|
||||||
CHAR16 *path,
|
const CHAR16 *path,
|
||||||
CHAR16 *file,
|
const CHAR16 *file,
|
||||||
CHAR8 *content,
|
CHAR8 *content,
|
||||||
CHAR16 *loaded_image_path) {
|
const CHAR16 *loaded_image_path) {
|
||||||
|
|
||||||
ConfigEntry *entry;
|
ConfigEntry *entry;
|
||||||
CHAR8 *line;
|
CHAR8 *line;
|
||||||
|
@ -1437,7 +1436,7 @@ static VOID config_load_entries(
|
||||||
EFI_FILE_HANDLE entries_dir;
|
EFI_FILE_HANDLE entries_dir;
|
||||||
EFI_STATUS err;
|
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)) {
|
if (!EFI_ERROR(err)) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
CHAR16 buf[256];
|
CHAR16 buf[256];
|
||||||
|
@ -1689,8 +1688,8 @@ static VOID config_title_generate(Config *config) {
|
||||||
|
|
||||||
static BOOLEAN config_entry_add_call(
|
static BOOLEAN config_entry_add_call(
|
||||||
Config *config,
|
Config *config,
|
||||||
CHAR16 *id,
|
const CHAR16 *id,
|
||||||
CHAR16 *title,
|
const CHAR16 *title,
|
||||||
EFI_STATUS (*call)(VOID)) {
|
EFI_STATUS (*call)(VOID)) {
|
||||||
|
|
||||||
ConfigEntry *entry;
|
ConfigEntry *entry;
|
||||||
|
@ -1713,11 +1712,11 @@ static ConfigEntry *config_entry_add_loader(
|
||||||
Config *config,
|
Config *config,
|
||||||
EFI_HANDLE *device,
|
EFI_HANDLE *device,
|
||||||
enum loader_type type,
|
enum loader_type type,
|
||||||
CHAR16 *id,
|
const CHAR16 *id,
|
||||||
CHAR16 key,
|
CHAR16 key,
|
||||||
CHAR16 *title,
|
const CHAR16 *title,
|
||||||
CHAR16 *loader,
|
const CHAR16 *loader,
|
||||||
CHAR16 *version) {
|
const CHAR16 *version) {
|
||||||
|
|
||||||
ConfigEntry *entry;
|
ConfigEntry *entry;
|
||||||
|
|
||||||
|
@ -1744,11 +1743,11 @@ static BOOLEAN config_entry_add_loader_auto(
|
||||||
Config *config,
|
Config *config,
|
||||||
EFI_HANDLE *device,
|
EFI_HANDLE *device,
|
||||||
EFI_FILE *root_dir,
|
EFI_FILE *root_dir,
|
||||||
CHAR16 *loaded_image_path,
|
const CHAR16 *loaded_image_path,
|
||||||
CHAR16 *id,
|
const CHAR16 *id,
|
||||||
CHAR16 key,
|
CHAR16 key,
|
||||||
CHAR16 *title,
|
const CHAR16 *title,
|
||||||
CHAR16 *loader) {
|
const CHAR16 *loader) {
|
||||||
|
|
||||||
EFI_FILE_HANDLE handle;
|
EFI_FILE_HANDLE handle;
|
||||||
ConfigEntry *entry;
|
ConfigEntry *entry;
|
||||||
|
@ -1774,7 +1773,7 @@ static BOOLEAN config_entry_add_loader_auto(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check existence */
|
/* 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))
|
if (EFI_ERROR(err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
uefi_call_wrapper(handle->Close, 1, handle);
|
uefi_call_wrapper(handle->Close, 1, handle);
|
||||||
|
@ -1824,7 +1823,7 @@ static VOID config_entry_add_linux(
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
ConfigEntry *entry;
|
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))
|
if (EFI_ERROR(err))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -175,23 +175,27 @@ if have_gnu_efi
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if have_gnu_efi
|
if have_gnu_efi
|
||||||
compile_args = ['-Wall',
|
compile_args = cc.get_supported_arguments(
|
||||||
'-Wextra',
|
basic_disabled_warnings +
|
||||||
'-std=gnu99',
|
possible_common_cc_flags + [
|
||||||
'-nostdlib',
|
'-ffreestanding',
|
||||||
|
'-fno-stack-protector',
|
||||||
'-fpic',
|
'-fpic',
|
||||||
'-fshort-wchar',
|
'-fshort-wchar',
|
||||||
'-ffreestanding',
|
'-Wall',
|
||||||
'-fno-strict-aliasing',
|
'-Wextra',
|
||||||
'-fno-stack-protector',
|
|
||||||
'-Wsign-compare',
|
'-Wsign-compare',
|
||||||
'-Wno-missing-field-initializers',
|
]
|
||||||
'-isystem', efi_incdir,
|
) + [
|
||||||
'-isystem', join_paths(efi_incdir, gnu_efi_path_arch),
|
'-nostdlib',
|
||||||
'-I', fundamental_path,
|
'-std=gnu99',
|
||||||
'-DSD_BOOT',
|
'-isystem', efi_incdir,
|
||||||
'-include', efi_config_h,
|
'-isystem', join_paths(efi_incdir, gnu_efi_path_arch),
|
||||||
'-include', version_h]
|
'-I', fundamental_path,
|
||||||
|
'-DSD_BOOT',
|
||||||
|
'-include', efi_config_h,
|
||||||
|
'-include', version_h,
|
||||||
|
]
|
||||||
if efi_arch == 'x86_64'
|
if efi_arch == 'x86_64'
|
||||||
compile_args += ['-mno-red-zone',
|
compile_args += ['-mno-red-zone',
|
||||||
'-mno-sse',
|
'-mno-sse',
|
||||||
|
|
|
@ -243,7 +243,7 @@ EFI_STATUS process_random_seed(EFI_FILE *root_dir, RandomSeedMode mode) {
|
||||||
if (mode != RANDOM_SEED_ALWAYS && EFI_ERROR(err))
|
if (mode != RANDOM_SEED_ALWAYS && EFI_ERROR(err))
|
||||||
return 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 (EFI_ERROR(err)) {
|
||||||
if (err != EFI_NOT_FOUND)
|
if (err != EFI_NOT_FOUND)
|
||||||
Print(L"Failed to open random seed file: %r\n", err);
|
Print(L"Failed to open random seed file: %r\n", err);
|
||||||
|
|
|
@ -143,9 +143,12 @@ void sha256_process_bytes(const void *buffer, UINTN len, struct sha256_ctx *ctx)
|
||||||
|
|
||||||
/* Process available complete blocks. */
|
/* Process available complete blocks. */
|
||||||
if (len >= 64) {
|
if (len >= 64) {
|
||||||
#if !_STRING_ARCH_unaligned
|
|
||||||
/* To check alignment gcc has an appropriate operator. Other
|
/* The condition below is from glibc's string/string-inline.c.
|
||||||
compilers don't. */
|
* 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
|
# if __GNUC__ >= 2
|
||||||
# define UNALIGNED_P(p) (((UINTN) p) % __alignof__ (UINT32) != 0)
|
# define UNALIGNED_P(p) (((UINTN) p) % __alignof__ (UINT32) != 0)
|
||||||
# else
|
# else
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <endian.h>
|
||||||
|
|
||||||
#include <efi.h>
|
#include <efi.h>
|
||||||
#include <efilib.h>
|
#include <efilib.h>
|
||||||
|
|
||||||
|
|
|
@ -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);
|
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];
|
CHAR16 str[32];
|
||||||
|
|
||||||
SPrint(str, 32, L"%u", i);
|
SPrint(str, 32, L"%u", i);
|
||||||
return efivar_set(vendor, name, str, flags);
|
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];
|
UINT8 buf[4];
|
||||||
|
|
||||||
buf[0] = (UINT8)(value >> 0U & 0xFF);
|
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);
|
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];
|
UINT8 buf[8];
|
||||||
|
|
||||||
buf[0] = (UINT8)(value >> 0U & 0xFF);
|
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;
|
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];
|
CHAR16 str[32];
|
||||||
|
|
||||||
if (usec == 0)
|
if (usec == 0)
|
||||||
|
@ -245,7 +245,7 @@ VOID efivar_set_time_usec(const EFI_GUID *vendor, CHAR16 *name, UINT64 usec) {
|
||||||
efivar_set(vendor, name, str, 0);
|
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;
|
CHAR16 unichar;
|
||||||
UINTN len;
|
UINTN len;
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ static INTN utf8_to_16(CHAR8 *stra, CHAR16 *c) {
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHAR16 *stra_to_str(CHAR8 *stra) {
|
CHAR16 *stra_to_str(const CHAR8 *stra) {
|
||||||
UINTN strlen;
|
UINTN strlen;
|
||||||
UINTN len;
|
UINTN len;
|
||||||
UINTN i;
|
UINTN i;
|
||||||
|
@ -324,7 +324,7 @@ CHAR16 *stra_to_str(CHAR8 *stra) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHAR16 *stra_to_path(CHAR8 *stra) {
|
CHAR16 *stra_to_path(const CHAR8 *stra) {
|
||||||
CHAR16 *str;
|
CHAR16 *str;
|
||||||
UINTN strlen;
|
UINTN strlen;
|
||||||
UINTN len;
|
UINTN len;
|
||||||
|
@ -361,10 +361,10 @@ CHAR16 *stra_to_path(CHAR8 *stra) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHAR8 *strchra(CHAR8 *s, CHAR8 c) {
|
CHAR8 *strchra(const CHAR8 *s, CHAR8 c) {
|
||||||
do {
|
do {
|
||||||
if (*s == c)
|
if (*s == c)
|
||||||
return s;
|
return (CHAR8*) s;
|
||||||
} while (*s++);
|
} while (*s++);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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(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_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_uint_string(const EFI_GUID *vendor, const 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_uint32_le(const EFI_GUID *vendor, const CHAR16 *NAME, UINT32 value, UINT32 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);
|
||||||
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);
|
||||||
|
|
||||||
EFI_STATUS efivar_get(const EFI_GUID *vendor, const CHAR16 *name, CHAR16 **value);
|
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);
|
EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const CHAR16 *name, CHAR8 **buffer, UINTN *size);
|
||||||
|
@ -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_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);
|
EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const CHAR16 *name, BOOLEAN *ret);
|
||||||
|
|
||||||
CHAR8 *strchra(CHAR8 *s, CHAR8 c);
|
CHAR8 *strchra(const CHAR8 *s, CHAR8 c);
|
||||||
CHAR16 *stra_to_path(CHAR8 *stra);
|
CHAR16 *stra_to_path(const CHAR8 *stra);
|
||||||
CHAR16 *stra_to_str(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);
|
EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN size, CHAR8 **content, UINTN *content_size);
|
||||||
|
|
||||||
|
|
|
@ -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.
|
* Note that except for '~' prefixed segments, a string has more segments is newer.
|
||||||
* So, this check must be after the '~' check. */
|
* So, this check must be after the '~' check. */
|
||||||
if (*a == '\0' || *b == '\0')
|
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 */
|
/* Handle '-', which separates version and release, e.g 123.4-3.1.fc33.x86_64 */
|
||||||
if (*a == '-' || *b == '-') {
|
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,
|
/* Find the leading numeric segments. One may be an empty string. So,
|
||||||
* numeric segments are always newer than alpha segments. */
|
* 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
|
/* 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;
|
return r;
|
||||||
} else {
|
} else {
|
||||||
/* Find the leading non-numeric segments. */
|
/* 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. */
|
/* Note that the segments are usually not NUL-terminated. */
|
||||||
|
|
Loading…
Reference in a new issue