mirror of
https://xff.cz/git/u-boot/
synced 2025-09-25 20:41:16 +02:00
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: 415eab0655
("smbios: add parsing API")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
@@ -6,21 +6,7 @@
|
|||||||
#define LOG_CATEGORY LOGC_BOOT
|
#define LOG_CATEGORY LOGC_BOOT
|
||||||
|
|
||||||
#include <smbios.h>
|
#include <smbios.h>
|
||||||
|
#include <tables_csum.h>
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct smbios_entry *smbios_entry(u64 address, u32 size)
|
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))
|
if (memcmp(entry->anchor, "_SM_", 4))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (verify_checksum(entry))
|
if (table_compute_checksum(entry, entry->length))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
|
Reference in New Issue
Block a user