From 0476fe09acd1b4a66613083f12a1b130237c1eaa Mon Sep 17 00:00:00 2001 From: stefanct Date: Mon, 13 Aug 2012 08:45:13 +0000 Subject: Clean up ICH descriptor code. - allows for compilation with -Werror=shadow, - use extended line limit to fix the most awful line breaks. Signed-off-by: Stefan Tauner Acked-by: Stefan Tauner git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1570 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- util/ich_descriptors_tool/ich_descriptors_tool.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'util') diff --git a/util/ich_descriptors_tool/ich_descriptors_tool.c b/util/ich_descriptors_tool/ich_descriptors_tool.c index 1ca970a..c359913 100644 --- a/util/ich_descriptors_tool/ich_descriptors_tool.c +++ b/util/ich_descriptors_tool/ich_descriptors_tool.c @@ -40,7 +40,7 @@ #include #endif -static void dump_file(const char *basename, const uint32_t *dump, unsigned int len, struct ich_desc_region *reg, unsigned int i) +static void dump_file(const char *prefix, const uint32_t *dump, unsigned int len, struct ich_desc_region *reg, unsigned int i) { int ret; char *fn; @@ -54,8 +54,7 @@ static void dump_file(const char *basename, const uint32_t *dump, unsigned int l reg_name = region_names[i]; if (base > limit) { - printf("The %s region is unused and thus not dumped.\n", - reg_name); + printf("The %s region is unused and thus not dumped.\n", reg_name); return; } @@ -68,13 +67,13 @@ static void dump_file(const char *basename, const uint32_t *dump, unsigned int l return; } - fn = malloc(strlen(basename) + strlen(reg_name) + strlen(".bin") + 2); + fn = malloc(strlen(prefix) + strlen(reg_name) + strlen(".bin") + 2); if (!fn) { fprintf(stderr, "Out of memory!\n"); exit(1); } - snprintf(fn, strlen(basename) + strlen(reg_name) + strlen(".bin") + 2, - "%s.%s.bin", basename, reg_name); + snprintf(fn, strlen(prefix) + strlen(reg_name) + strlen(".bin") + 2, + "%s.%s.bin", prefix, reg_name); printf("Dumping %u bytes of the %s region from 0x%08x-0x%08x to %s... ", file_len, region_names[i], base, limit, fn); int fh = open(fn, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); @@ -95,12 +94,12 @@ static void dump_file(const char *basename, const uint32_t *dump, unsigned int l close(fh); } -void dump_files(const char *n, const uint32_t *buf, unsigned int len, struct ich_desc_region *reg) +void dump_files(const char *name, const uint32_t *buf, unsigned int len, struct ich_desc_region *reg) { unsigned int i; printf("=== Dumping region files ===\n"); for (i = 0; i < 5; i++) - dump_file(n, buf, len, reg, i); + dump_file(name, buf, len, reg, i); printf("\n"); } @@ -157,8 +156,7 @@ int main(int argc, char *argv[]) } } if (fn == NULL) - usage(argv, - "Need a file name of a descriptor image to read from."); + usage(argv, "Need the file name of a descriptor image to read from."); fd = open(fn, O_RDONLY); if (fd < 0) @@ -209,8 +207,7 @@ int main(int argc, char *argv[]) printf("Image not in descriptor mode.\n"); exit(1); case ICH_RET_OOB: - printf("Tried to access a location out of bounds of the image. " - "- Corrupt image?\n"); + printf("Tried to access a location out of bounds of the image. - Corrupt image?\n"); exit(1); default: printf("Unhandled return value at %s:%u, please report this.\n", -- cgit v1.2.1