1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 14:11:15 +02:00

Clean up ICH descriptor code

- allows for compilation with -Werror=shadow,
 - use extended line limit to fix the most awful line breaks.

Corresponding to flashrom svn r1570.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
This commit is contained in:
Stefan Tauner
2012-08-13 08:45:13 +00:00
parent 37e8686284
commit a1a14ec5d2
2 changed files with 52 additions and 74 deletions

View File

@ -40,7 +40,7 @@
#include <sys/mman.h>
#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",