From: Yu Watanabe Date: Fri, 11 Oct 2024 18:52:10 +0000 (+0900) Subject: boot/efi: trivial coding style cleanups X-Git-Tag: v257-rc1~241^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f87e02ba3f281b79fd357b00ba06820b9ba6ceaa;p=thirdparty%2Fsystemd.git boot/efi: trivial coding style cleanups Follow-ups for #34717 and #34718. --- diff --git a/src/boot/efi/smbios.c b/src/boot/efi/smbios.c index 997428a9c48..89a186e26ac 100644 --- a/src/boot/efi/smbios.c +++ b/src/boot/efi/smbios.c @@ -186,13 +186,10 @@ const char* smbios_find_oem_string(const char *name) { if (!type11) return NULL; - const char *s = type11->contents; - assert(left >= type11->header.length); /* get_smbios_table() already validated this */ left -= type11->header.length; - const char *limit = s + left; - for (const char *p = s; p < limit; ) { + for (const char *p = type11->contents, *limit = type11->contents + left; p < limit; ) { const char *e = memchr(p, 0, limit - p); if (!e || e == p) /* Double NUL byte means we've reached the end of the OEM strings. */ break; @@ -208,8 +205,7 @@ const char* smbios_find_oem_string(const char *name) { } static const char* smbios_get_string(const SmbiosHeader *header, size_t nr, uint64_t left) { - assert(header); - const char *s = (const char *) header; + const char *s = (const char *) ASSERT_PTR(header); /* We assume that get_smbios_table() already validated the header size making some superficial sense */ assert(left >= header->length); @@ -227,13 +223,15 @@ static const char* smbios_get_string(const SmbiosHeader *header, size_t nr, uint p = e + 1; } + return NULL; } void smbios_raw_info_populate(RawSmbiosInfo *ret_info) { - assert(ret_info); uint64_t left; + assert(ret_info); + const SmbiosTableType1 *type1 = (const SmbiosTableType1 *) get_smbios_table(1, sizeof(SmbiosTableType1), &left); if (type1) { ret_info->manufacturer = smbios_get_string(&type1->header, type1->manufacturer, left); diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index 35f6c80a022..054d49ef02b 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -4,8 +4,8 @@ #include "efi.h" #include "efi-string.h" #include "log.h" -#include "proto/file-io.h" #include "memory-util-fundamental.h" +#include "proto/file-io.h" #include "string-util-fundamental.h" /* This is provided by the linker. */