From fb67588c62ba81b07e0074c61012c8a0db987684 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Tue, 24 May 2022 10:26:35 +0200 Subject: [PATCH] boot: Use strchr8/16 --- src/boot/efi/boot.c | 10 +++++----- src/boot/efi/cpio.c | 2 +- src/boot/efi/util.c | 12 ------------ src/boot/efi/util.h | 1 - 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 813e92d675..1b45aef50b 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -1092,7 +1092,7 @@ static CHAR8 *line_get_key_value( return NULL; linelen = 0; - while (line[linelen] && !strchra((CHAR8 *) "\n\r", line[linelen])) + while (line[linelen] && !strchr8("\n\r", line[linelen])) linelen++; /* move pos to next line */ @@ -1108,13 +1108,13 @@ static CHAR8 *line_get_key_value( line[linelen] = '\0'; /* remove leading whitespace */ - while (strchra((CHAR8 *) " \t", *line)) { + while (strchr8(" \t", *line)) { line++; linelen--; } /* remove trailing whitespace */ - while (linelen > 0 && strchra((CHAR8 *) " \t", line[linelen - 1])) + while (linelen > 0 && strchr8(" \t", line[linelen - 1])) linelen--; line[linelen] = '\0'; @@ -1123,13 +1123,13 @@ static CHAR8 *line_get_key_value( /* split key/value */ value = line; - while (*value && !strchra(sep, *value)) + while (*value && !strchr8((char *) sep, *value)) value++; if (*value == '\0') continue; *value = '\0'; value++; - while (*value && strchra(sep, *value)) + while (*value && strchr8((char *) sep, *value)) value++; /* unquote */ diff --git a/src/boot/efi/cpio.c b/src/boot/efi/cpio.c index 13da1ca0f8..5f8489635f 100644 --- a/src/boot/efi/cpio.c +++ b/src/boot/efi/cpio.c @@ -248,7 +248,7 @@ static EFI_STATUS pack_cpio_prefix( for (const CHAR8 *p = path;;) { const CHAR8 *e; - e = strchra(p, '/'); + e = (const CHAR8 *) strchr8((const char *) p, '/'); if (!e) break; diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c index 6e4e914f43..e344c450c8 100644 --- a/src/boot/efi/util.c +++ b/src/boot/efi/util.c @@ -359,18 +359,6 @@ CHAR16 *xstra_to_path(const CHAR8 *stra) { return str; } -CHAR8 *strchra(const CHAR8 *s, CHAR8 c) { - if (!s) - return NULL; - - do { - if (*s == c) - return (CHAR8*) s; - } while (*s++); - - return NULL; -} - EFI_STATUS file_read(EFI_FILE *dir, const CHAR16 *name, UINTN off, UINTN size, CHAR8 **ret, UINTN *ret_size) { _cleanup_(file_closep) EFI_FILE *handle = NULL; _cleanup_freepool_ CHAR8 *buf = NULL; diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index 57efd692d1..2a50336f32 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -61,7 +61,6 @@ 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(const CHAR8 *s, CHAR8 c); CHAR16 *xstra_to_path(const CHAR8 *stra); CHAR16 *xstra_to_str(const CHAR8 *stra);