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

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.
Fixes: 3d49ee8510d3 ("efi_loader: add SMBIOS table measurement") Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- lib/smbios-parser.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
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; -- 2.43.0

Hi Heinrich,
On Fri, 22 Dec 2023 at 19:54, Heinrich Schuchardt xypron.glpk@gmx.de 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.
Fixes: 3d49ee8510d3 ("efi_loader: add SMBIOS table measurement")\
This doesn't fix a bug. It correctly cleans up code, so I think the Fixes tag must be omitted.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
lib/smbios-parser.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
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;
-- 2.43.0
Other than that Reviewed-by: Ilias Apalodimas ilias.apalodimas@linaro.org

On Fri, Dec 22, 2023 at 5:59 PM Heinrich Schuchardt xypron.glpk@gmx.de 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.
Fixes: 3d49ee8510d3 ("efi_loader: add SMBIOS table measurement")
Yes, please drop that
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
lib/smbios-parser.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
participants (3)
-
Heinrich Schuchardt
-
Ilias Apalodimas
-
Simon Glass