From f87e02ba3f281b79fd357b00ba06820b9ba6ceaa Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 12 Oct 2024 03:52:10 +0900 Subject: [PATCH] boot/efi: trivial coding style cleanups Follow-ups for #34717 and #34718. --- src/boot/efi/smbios.c | 12 +++++------- src/boot/efi/util.h | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) 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. */ -- 2.47.3