[coreboot-gerrit] New patch to review for coreboot: cbfstool: drop extra copy of filetype->string map
Patrick Georgi (pgeorgi@google.com)
gerrit at coreboot.org
Fri Sep 11 16:42:20 CET 2015
Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11626
-gerrit
commit c02a13b4f90f5545a8c58921d503ffdf201f8d9d
Author: Patrick Georgi <pgeorgi at chromium.org>
Date: Wed Sep 9 16:46:00 2015 +0200
cbfstool: drop extra copy of filetype->string map
We had two mappings of filetype IDs to strings. We shouldn't.
Change-Id: I08e478b92f3316139f14294e50ede657c7d5fb01
Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
---
util/cbfstool/cbfs.h | 24 ++++++++++++++++++++++++
util/cbfstool/cbfs_image.c | 27 +--------------------------
util/cbfstool/common.c | 24 +-----------------------
3 files changed, 26 insertions(+), 49 deletions(-)
diff --git a/util/cbfstool/cbfs.h b/util/cbfstool/cbfs.h
index f738c60..70f806b 100644
--- a/util/cbfstool/cbfs.h
+++ b/util/cbfstool/cbfs.h
@@ -175,6 +175,30 @@ struct cbfs_payload {
*/
#define CBFS_COMPONENT_NULL 0xFFFFFFFF
+struct typedesc_t {
+ uint32_t type;
+ const char *name;
+};
+
+static struct typedesc_t filetypes[] unused = {
+ {CBFS_COMPONENT_STAGE, "stage"},
+ {CBFS_COMPONENT_PAYLOAD, "payload"},
+ {CBFS_COMPONENT_OPTIONROM, "optionrom"},
+ {CBFS_COMPONENT_BOOTSPLASH, "bootsplash"},
+ {CBFS_COMPONENT_RAW, "raw"},
+ {CBFS_COMPONENT_VSA, "vsa"},
+ {CBFS_COMPONENT_MBI, "mbi"},
+ {CBFS_COMPONENT_MICROCODE, "microcode"},
+ {CBFS_COMPONENT_FSP, "fsp"},
+ {CBFS_COMPONENT_MRC, "mrc"},
+ {CBFS_COMPONENT_CMOS_DEFAULT, "cmos_default"},
+ {CBFS_COMPONENT_CMOS_LAYOUT, "cmos_layout"},
+ {CBFS_COMPONENT_SPD, "spd"},
+ {CBFS_COMPONENT_MRC_CACHE, "mrc_cache"},
+ {CBFS_COMPONENT_DELETED, "deleted"},
+ {CBFS_COMPONENT_NULL, "null"}
+};
+
#define CBFS_SUBHEADER(_p) ( (void *) ((((uint8_t *) (_p)) + ntohl((_p)->offset))) )
/* cbfs_image.c */
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index c40bd66..c2f0b37 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -52,31 +52,6 @@
/* Type and format */
-struct typedesc_t {
- uint32_t type;
- const char *name;
-};
-
-static const struct typedesc_t types_cbfs_entry[] = {
- {CBFS_COMPONENT_STAGE, "stage"},
- {CBFS_COMPONENT_PAYLOAD, "payload"},
- {CBFS_COMPONENT_OPTIONROM, "optionrom"},
- {CBFS_COMPONENT_BOOTSPLASH, "bootsplash"},
- {CBFS_COMPONENT_RAW, "raw"},
- {CBFS_COMPONENT_VSA, "vsa"},
- {CBFS_COMPONENT_MBI, "mbi"},
- {CBFS_COMPONENT_MICROCODE, "microcode"},
- {CBFS_COMPONENT_FSP, "fsp"},
- {CBFS_COMPONENT_MRC, "mrc"},
- {CBFS_COMPONENT_CMOS_DEFAULT, "cmos_default"},
- {CBFS_COMPONENT_CMOS_LAYOUT, "cmos_layout"},
- {CBFS_COMPONENT_SPD, "spd"},
- {CBFS_COMPONENT_MRC_CACHE, "mrc_cache"},
- {CBFS_COMPONENT_DELETED, "deleted"},
- {CBFS_COMPONENT_NULL, "null"},
- {0, NULL}
-};
-
static const struct typedesc_t types_cbfs_compression[] = {
{CBFS_COMPRESS_NONE, "none"},
{CBFS_COMPRESS_LZMA, "LZMA"},
@@ -102,7 +77,7 @@ static int lookup_type_by_name(const struct typedesc_t *desc, const char *name)
static const char *get_cbfs_entry_type_name(uint32_t type)
{
- return lookup_name_by_type(types_cbfs_entry, type, "(unknown)");
+ return lookup_name_by_type(filetypes, type, "(unknown)");
}
int cbfs_parse_comp_algo(const char *name)
diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c
index d72db38..f8ce2f9 100644
--- a/util/cbfstool/common.c
+++ b/util/cbfstool/common.c
@@ -177,28 +177,6 @@ const char *arch_to_string(uint32_t a)
return ret;
}
-static struct filetypes_t {
- uint32_t type;
- const char *name;
-} filetypes[] = {
- {CBFS_COMPONENT_STAGE, "stage"},
- {CBFS_COMPONENT_PAYLOAD, "payload"},
- {CBFS_COMPONENT_OPTIONROM, "optionrom"},
- {CBFS_COMPONENT_BOOTSPLASH, "bootsplash"},
- {CBFS_COMPONENT_RAW, "raw"},
- {CBFS_COMPONENT_VSA, "vsa"},
- {CBFS_COMPONENT_MBI, "mbi"},
- {CBFS_COMPONENT_MICROCODE, "microcode"},
- {CBFS_COMPONENT_FSP, "fsp"},
- {CBFS_COMPONENT_MRC, "mrc"},
- {CBFS_COMPONENT_CMOS_DEFAULT, "cmos default"},
- {CBFS_COMPONENT_CMOS_LAYOUT, "cmos layout"},
- {CBFS_COMPONENT_SPD, "spd"},
- {CBFS_COMPONENT_MRC_CACHE, "mrc_cache"},
- {CBFS_COMPONENT_DELETED, "deleted"},
- {CBFS_COMPONENT_NULL, "null"}
-};
-
void print_supported_filetypes(void)
{
int i, number = ARRAY_SIZE(filetypes);
@@ -213,7 +191,7 @@ void print_supported_filetypes(void)
uint64_t intfiletype(const char *name)
{
size_t i;
- for (i = 0; i < (sizeof(filetypes) / sizeof(struct filetypes_t)); i++)
+ for (i = 0; i < (sizeof(filetypes) / sizeof(struct typedesc_t)); i++)
if (strcmp(filetypes[i].name, name) == 0)
return filetypes[i].type;
return -1;
More information about the coreboot-gerrit
mailing list