Werner Zeh submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Patrick Rudolph: Looks good to me, approved Tim Wawrzynczak: Looks good to me, approved
arch/x86/smbios.c: Trim some `len` variables

Reduce the scope or remove some `len` variables. This is done to ease
replacing `sizeof` on struct types in a follow-up commit, by ensuring
that all to-be-replaced appearances follow the variable declarations.

Change-Id: Ied38fcaf87ef5b1e4f93076b4ba2898ad1f98a72
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55903
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
---
M src/arch/x86/smbios.c
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c
index 9b47ff6..b21cf67 100644
--- a/src/arch/x86/smbios.c
+++ b/src/arch/x86/smbios.c
@@ -902,7 +902,6 @@
const struct port_information *port,
size_t num_ports)
{
- int len = sizeof(struct smbios_type8);
unsigned int totallen = 0, i;

for (i = 0; i < num_ports; i++, port++) {
@@ -910,7 +909,7 @@
memset(t, 0, sizeof(struct smbios_type8));
t->type = SMBIOS_PORT_CONNECTOR_INFORMATION;
t->handle = *handle;
- t->length = len - 2;
+ t->length = sizeof(struct smbios_type8) - 2;
t->internal_reference_designator =
smbios_add_string(t->eos, port->internal_reference_designator);
t->internal_connector_type = port->internal_connector_type;
@@ -1041,7 +1040,6 @@

static int smbios_write_type17(unsigned long *current, int *handle, int type16)
{
- int len = sizeof(struct smbios_type17);
int totallen = 0;
int i;

@@ -1060,7 +1058,7 @@
* Otherwise, the physical installed memory size is guessed from the system
* memory map, which results in a slightly smaller value than the actual size.
*/
- len = create_smbios_type17_for_dimm(dimm, current, handle, type16);
+ const int len = create_smbios_type17_for_dimm(dimm, current, handle, type16);
*current += len;
totallen += len;
}
@@ -1070,7 +1068,6 @@
static int smbios_write_type19(unsigned long *current, int *handle, int type16)
{
struct smbios_type19 *t = (struct smbios_type19 *)*current;
- int len = sizeof(struct smbios_type19);
int i;

struct memory_info *meminfo;
@@ -1081,7 +1078,7 @@
memset(t, 0, sizeof(struct smbios_type19));

t->type = SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS;
- t->length = len - 2;
+ t->length = sizeof(struct smbios_type19) - 2;
t->handle = *handle;
t->memory_array_handle = type16;

@@ -1112,7 +1109,7 @@
t->extended_ending_address--;
}

- len = t->length + smbios_string_table_len(t->eos);
+ const int len = t->length + smbios_string_table_len(t->eos);
*current += len;
*handle += 1;
return len;

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

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ied38fcaf87ef5b1e4f93076b4ba2898ad1f98a72
Gerrit-Change-Number: 55903
Gerrit-PatchSet: 2
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Patrick Rudolph <siro@das-labor.org>
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