Patrick Georgi submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Michał Żygowski: Looks good to me, approved Tim Wawrzynczak: Looks good to me, approved
mb/pcengines/apuX: Refactor to avoid dead assignment

The initial value of `len` is never used. Declare and initialise all
local variables in a single statement to avoid this problem.

Change-Id: Ieb96758f4cd19d9d3f8fdc543e8ca17db06a2123
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55905
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
---
M src/mainboard/pcengines/apu1/mainboard.c
M src/mainboard/pcengines/apu2/mainboard.c
2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/mainboard/pcengines/apu1/mainboard.c b/src/mainboard/pcengines/apu1/mainboard.c
index 05c496d..187f8cf 100644
--- a/src/mainboard/pcengines/apu1/mainboard.c
+++ b/src/mainboard/pcengines/apu1/mainboard.c
@@ -168,14 +168,11 @@
#if CONFIG(GENERATE_SMBIOS_TABLES)
static int mainboard_smbios_type16(DMI_INFO *agesa_dmi, int *handle, unsigned long *current)
{
- struct smbios_type16 *t;
- u32 max_capacity;
- int len;
+ const u32 max_capacity = get_spd_offset() ? 4 : 2; /* 4GB or 2GB variant */

- t = (struct smbios_type16 *)*current;
- len = sizeof(*t);
+ struct smbios_type16 *t = (struct smbios_type16 *)*current;
+ int len = sizeof(*t);
memset(t, 0, len);
- max_capacity = get_spd_offset() ? 4 : 2; /* 4GB or 2GB variant */

t->type = SMBIOS_PHYS_MEMORY_ARRAY;
t->handle = *handle;
diff --git a/src/mainboard/pcengines/apu2/mainboard.c b/src/mainboard/pcengines/apu2/mainboard.c
index bcf2536..2c3b861 100644
--- a/src/mainboard/pcengines/apu2/mainboard.c
+++ b/src/mainboard/pcengines/apu2/mainboard.c
@@ -150,14 +150,11 @@
static int mainboard_smbios_type16(DMI_INFO *agesa_dmi, int *handle,
unsigned long *current)
{
- struct smbios_type16 *t;
- u32 max_capacity;
- int len = 0;
+ const u32 max_capacity = get_spd_offset() ? 4 : 2; /* 4GB or 2GB variant */

- t = (struct smbios_type16 *)*current;
- len = sizeof(*t);
+ struct smbios_type16 *t = (struct smbios_type16 *)*current;
+ int len = sizeof(*t);
memset(t, 0, len);
- max_capacity = get_spd_offset() ? 4 : 2; /* 4GB or 2GB variant */

t->type = SMBIOS_PHYS_MEMORY_ARRAY;
t->handle = *handle;

To view, visit change 55905. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ieb96758f4cd19d9d3f8fdc543e8ca17db06a2123
Gerrit-Change-Number: 55905
Gerrit-PatchSet: 2
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-Reviewer: Michał Żygowski <michal.zygowski@3mdeb.com>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Patrick Georgi <pgeorgi@google.com>
Gerrit-Reviewer: Patrick Rudolph <siro@das-labor.org>
Gerrit-Reviewer: Piotr Król <piotr.krol@3mdeb.com>
Gerrit-Reviewer: Tim Wawrzynczak <twawrzynczak@chromium.org>
Gerrit-Reviewer: Werner Zeh <werner.zeh@siemens.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@mailbox.org>
Gerrit-MessageType: merged