diff mbox series

[v2,1/1] lib: smbios: remove redundant next_header()

Message ID 20231223011734.248809-1-xypron.glpk@gmx.de
State Accepted
Commit ddcfb9ede8da45ebbdb1c4facf07b0f0b735373f
Delegated to: Tom Rini
Headers show
Series [v2,1/1] lib: smbios: remove redundant next_header() | expand

Commit Message

Heinrich Schuchardt Dec. 23, 2023, 1:17 a.m. UTC
next_header() and get_next_header() only differ in how the const attribute
is used. One function taking a const parameter and returning a non-const is
good enough.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
v2:
	remove Fixes tag as the code redundancy is not an actual bug
---
 lib/smbios-parser.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

--
2.43.0

Comments

Tom Rini Jan. 17, 2024, 2:27 p.m. UTC | #1
On Sat, Dec 23, 2023 at 02:17:33AM +0100, Heinrich Schuchardt wrote:

> next_header() and get_next_header() only differ in how the const attribute
> is used. One function taking a const parameter and returning a non-const is
> good enough.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/lib/smbios-parser.c b/lib/smbios-parser.c
index b578c30840..f4de350e6e 100644
--- a/lib/smbios-parser.c
+++ b/lib/smbios-parser.c
@@ -50,14 +50,7 @@  static u8 *find_next_header(u8 *pos)
 	return pos;
 }

-static struct smbios_header *get_next_header(struct smbios_header *curr)
-{
-	u8 *pos = ((u8 *)curr) + curr->length;
-
-	return (struct smbios_header *)find_next_header(pos);
-}
-
-static const struct smbios_header *next_header(const struct smbios_header *curr)
+static struct smbios_header *get_next_header(const struct smbios_header *curr)
 {
 	u8 *pos = ((u8 *)curr) + curr->length;

@@ -73,7 +66,7 @@  const struct smbios_header *smbios_header(const struct smbios_entry *entry, int
 		if (header->type == type)
 			return header;

-		header = next_header(header);
+		header = get_next_header(header);
 	}

 	return NULL;