diff options
author | Angel Pons <th3fanbus@gmail.com> | 2021-06-28 15:36:23 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2021-07-01 07:35:02 +0000 |
commit | 35b99c64e62fd84866dd269a3641b66646f9557f (patch) | |
tree | 8a95363becb766da16e47fadbe87ebca9a5fe06e /src/mainboard | |
parent | c6dab80b1cd8fb35115e9876b79abefb6c4f2d91 (diff) |
SMBIOS: Avoid `sizeof` on struct type
Where applicable, use the size of the associated variable.
Change-Id: Ibbac2a82893232a6f87182a6a965b84a599d633e
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55904
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Diffstat (limited to 'src/mainboard')
-rw-r--r-- | src/mainboard/emulation/qemu-i440fx/northbridge.c | 8 | ||||
-rw-r--r-- | src/mainboard/pcengines/apu1/mainboard.c | 6 | ||||
-rw-r--r-- | src/mainboard/pcengines/apu2/mainboard.c | 6 | ||||
-rw-r--r-- | src/mainboard/samsung/lumpy/mainboard.c | 4 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/mainboard/emulation/qemu-i440fx/northbridge.c b/src/mainboard/emulation/qemu-i440fx/northbridge.c index 8579b8f886..01d036a6a0 100644 --- a/src/mainboard/emulation/qemu-i440fx/northbridge.c +++ b/src/mainboard/emulation/qemu-i440fx/northbridge.c @@ -166,9 +166,9 @@ static void cpu_pci_domain_read_resources(struct device *dev) static int qemu_get_smbios_data16(int handle, unsigned long *current) { struct smbios_type16 *t = (struct smbios_type16 *)*current; - int len = sizeof(struct smbios_type16); + int len = sizeof(*t); - memset(t, 0, sizeof(struct smbios_type16)); + memset(t, 0, sizeof(*t)); t->type = SMBIOS_PHYS_MEMORY_ARRAY; t->handle = handle; t->length = len - 2; @@ -185,11 +185,11 @@ static int qemu_get_smbios_data17(int handle, int parent_handle, unsigned long * struct smbios_type17 *t = (struct smbios_type17 *)*current; int len; - memset(t, 0, sizeof(struct smbios_type17)); + memset(t, 0, sizeof(*t)); t->type = SMBIOS_MEMORY_DEVICE; t->handle = handle; t->phys_memory_array_handle = parent_handle; - t->length = sizeof(struct smbios_type17) - 2; + t->length = sizeof(*t) - 2; t->size = qemu_get_memory_size() / 1024; t->data_width = 64; t->total_width = 64; diff --git a/src/mainboard/pcengines/apu1/mainboard.c b/src/mainboard/pcengines/apu1/mainboard.c index cb5d4fba8d..05c496dc57 100644 --- a/src/mainboard/pcengines/apu1/mainboard.c +++ b/src/mainboard/pcengines/apu1/mainboard.c @@ -173,7 +173,7 @@ static int mainboard_smbios_type16(DMI_INFO *agesa_dmi, int *handle, unsigned lo int len; t = (struct smbios_type16 *)*current; - len = sizeof(struct smbios_type16); + len = sizeof(*t); memset(t, 0, len); max_capacity = get_spd_offset() ? 4 : 2; /* 4GB or 2GB variant */ @@ -199,10 +199,10 @@ static int mainboard_smbios_type17(DMI_INFO *agesa_dmi, int *handle, unsigned lo int len; t = (struct smbios_type17 *)*current; - memset(t, 0, sizeof(struct smbios_type17)); + memset(t, 0, sizeof(*t)); t->type = SMBIOS_MEMORY_DEVICE; - t->length = sizeof(struct smbios_type17) - 2; + t->length = sizeof(*t) - 2; t->handle = *handle + 1; t->phys_memory_array_handle = *handle; t->memory_error_information_handle = 0xfffe; diff --git a/src/mainboard/pcengines/apu2/mainboard.c b/src/mainboard/pcengines/apu2/mainboard.c index 56976e53c5..bcf2536237 100644 --- a/src/mainboard/pcengines/apu2/mainboard.c +++ b/src/mainboard/pcengines/apu2/mainboard.c @@ -155,7 +155,7 @@ static int mainboard_smbios_type16(DMI_INFO *agesa_dmi, int *handle, int len = 0; t = (struct smbios_type16 *)*current; - len = sizeof(struct smbios_type16); + len = sizeof(*t); memset(t, 0, len); max_capacity = get_spd_offset() ? 4 : 2; /* 4GB or 2GB variant */ @@ -182,10 +182,10 @@ static int mainboard_smbios_type17(DMI_INFO *agesa_dmi, int *handle, int len; t = (struct smbios_type17 *)*current; - memset(t, 0, sizeof(struct smbios_type17)); + memset(t, 0, sizeof(*t)); t->type = SMBIOS_MEMORY_DEVICE; - t->length = sizeof(struct smbios_type17) - 2; + t->length = sizeof(*t) - 2; t->handle = *handle + 1; t->phys_memory_array_handle = *handle; t->memory_error_information_handle = 0xfffe; diff --git a/src/mainboard/samsung/lumpy/mainboard.c b/src/mainboard/samsung/lumpy/mainboard.c index cdeaf72de0..c2899b8e25 100644 --- a/src/mainboard/samsung/lumpy/mainboard.c +++ b/src/mainboard/samsung/lumpy/mainboard.c @@ -29,9 +29,9 @@ static int lumpy_smbios_type41_irq(int *handle, unsigned long *current, const char *name, u8 irq, u8 addr) { struct smbios_type41 *t = (struct smbios_type41 *)*current; - int len = sizeof(struct smbios_type41); + int len = sizeof(*t); - memset(t, 0, sizeof(struct smbios_type41)); + memset(t, 0, sizeof(*t)); t->type = SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION; t->handle = *handle; t->length = len - 2; |