From: Heinrich Schuchardt Date: Tue, 26 Dec 2023 10:22:28 +0000 (+0100) Subject: lib: smbios: verify_checksum() is duplicate X-Git-Url: http://git.dujemihanovic.xyz/repo?a=commitdiff_plain;h=dc2fe5d84ea1f285fa0ad1052deee742c8f593e3;p=u-boot.git lib: smbios: verify_checksum() is duplicate The function verify_checksum() duplicates what table_compute_checksum() does. Replace it. table_compute_checksum() is always compiled. Fixes: 415eab0655a8 ("smbios: add parsing API") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Reviewed-by: Ilias Apalodimas --- diff --git a/lib/smbios-parser.c b/lib/smbios-parser.c index b578c30840..4a3732bcf2 100644 --- a/lib/smbios-parser.c +++ b/lib/smbios-parser.c @@ -6,21 +6,7 @@ #define LOG_CATEGORY LOGC_BOOT #include - -static inline int verify_checksum(const struct smbios_entry *e) -{ - /* - * Checksums for SMBIOS tables are calculated to have a value, so that - * the sum over all bytes yields zero (using unsigned 8 bit arithmetic). - */ - u8 *byte = (u8 *)e; - u8 sum = 0; - - for (int i = 0; i < e->length; i++) - sum += byte[i]; - - return sum; -} +#include const struct smbios_entry *smbios_entry(u64 address, u32 size) { @@ -32,7 +18,7 @@ const struct smbios_entry *smbios_entry(u64 address, u32 size) if (memcmp(entry->anchor, "_SM_", 4)) return NULL; - if (verify_checksum(entry)) + if (table_compute_checksum(entry, entry->length)) return NULL; return entry;