Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at --- chipset_enable.c | 5 ++++- flashrom.c | 18 ++++++++++-------- print.c | 9 +++++++-- print_wiki.c | 5 ++++- 4 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/chipset_enable.c b/chipset_enable.c index 83b49ad..595e926 100644 --- a/chipset_enable.c +++ b/chipset_enable.c @@ -1177,6 +1177,7 @@ int chipset_flash_enable(void) struct pci_dev *dev = NULL; int ret = -2; /* Nothing! */ int i; + char *tmp_bus_str;
/* Now let's try to find the chipset we have... */ for (i = 0; chipset_enables[i].vendor_name != NULL; i++) { @@ -1215,8 +1216,10 @@ int chipset_flash_enable(void) msg_pinfo("PROBLEMS, continuing anyway\n"); }
+ tmp_bus_str = flashbuses_to_text(buses_supported); msg_pinfo("This chipset supports the following protocols: %s.\n", - flashbuses_to_text(buses_supported)); + tmp_bus_str); + free(tmp_bus_str);
return ret; } diff --git a/flashrom.c b/flashrom.c index e9e6a77..224524a 100644 --- a/flashrom.c +++ b/flashrom.c @@ -1135,7 +1135,7 @@ int probe_flash(int startchip, struct flashchip *fill_flash, int force) char location[64]; uint32_t size; enum chipbustype buses_common; - char *tmp; + char *tmp_bus_str;
for (flash = flashchips + startchip; flash && flash->name; flash++) { if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) @@ -1149,14 +1149,14 @@ int probe_flash(int startchip, struct flashchip *fill_flash, int force) } buses_common = buses_supported & flash->bustype; if (!buses_common) { - tmp = flashbuses_to_text(buses_supported); + tmp_bus_str = flashbuses_to_text(buses_supported); msg_gdbg("skipped."); - msg_gspew(" Host bus type %s ", tmp); - free(tmp); - tmp = flashbuses_to_text(flash->bustype); + msg_gspew(" Host bus type %s ", tmp_bus_str); + free(tmp_bus_str); + tmp_bus_str = flashbuses_to_text(flash->bustype); msg_gspew("and chip bus type %s are incompatible.", - tmp); - free(tmp); + tmp_bus_str); + free(tmp_bus_str); msg_gdbg("\n"); continue; } @@ -1201,10 +1201,12 @@ notfound: #endif snprintf(location, sizeof(location), "on %s", programmer_table[programmer].name);
+ tmp_bus_str = flashbuses_to_text(flash->bustype); msg_cinfo("%s chip "%s %s" (%d kB, %s) %s.\n", force ? "Assuming" : "Found", flash->vendor, flash->name, flash->total_size, - flashbuses_to_text(flash->bustype), location); + tmp_bus_str, location); + free(tmp_bus_str);
/* Flash registers will not be mapped if the chip was forced. Lock info * may be stored in registers, so avoid lock info printing. diff --git a/print.c b/print.c index 830ee8a..5d1b449 100644 --- a/print.c +++ b/print.c @@ -28,7 +28,7 @@
/* * Return a string corresponding to the bustype parameter. - * Memory is obtained with malloc() and can be freed with free(). + * Memory is obtained with malloc() and must be freed with free() by the caller. */ char *flashbuses_to_text(enum chipbustype bustype) { @@ -80,6 +80,7 @@ static void print_supported_chips(void) int maxvendorlen = strlen("Vendor") + 1; int maxchiplen = strlen("Device") + 1; const struct flashchip *f; + char *tmp_bus_str;
for (f = flashchips; f->name != NULL; f++) { /* Ignore "unknown XXXX SPI chip" entries. */ @@ -152,7 +153,11 @@ static void print_supported_chips(void) msg_ginfo("%d", f->total_size); for (i = 0; i < 10 - digits(f->total_size); i++) msg_ginfo(" "); - msg_ginfo("%s\n", flashbuses_to_text(f->bustype)); + + tmp_bus_str = flashbuses_to_text(f->bustype); + msg_ginfo("%s", tmp_bus_str); + free(tmp_bus_str); + msg_ginfo("\n"); } }
diff --git a/print_wiki.c b/print_wiki.c index dadba49..0fcc32a 100644 --- a/print_wiki.c +++ b/print_wiki.c @@ -203,6 +203,7 @@ static void print_supported_chips_wiki(int cols) int i = 0, c = 1, chipcount = 0; const struct flashchip *f, *old = NULL; uint32_t t; + char *tmp_bus_str;
for (f = flashchips; f->name != NULL; f++) chipcount++; @@ -221,10 +222,11 @@ static void print_supported_chips_wiki(int cols) c = !c;
t = f->tested; + tmp_bus_str = flashbuses_to_text(f->bustype); printf("|- bgcolor="#%s"\n| %s || %s || %d " "|| %s || {{%s}} || {{%s}} || {{%s}} || {{%s}}\n", (c == 1) ? "eeeeee" : "dddddd", f->vendor, f->name, - f->total_size, flashbuses_to_text(f->bustype), + f->total_size, tmp_bus_str, (t & TEST_OK_PROBE) ? "OK" : (t & TEST_BAD_PROBE) ? "No" : "?3", (t & TEST_OK_READ) ? "OK" : @@ -233,6 +235,7 @@ static void print_supported_chips_wiki(int cols) (t & TEST_BAD_ERASE) ? "No" : "?3", (t & TEST_OK_WRITE) ? "OK" : (t & TEST_BAD_WRITE) ? "No" : "?3"); + free(tmp_bus_str);
/* Split table into 'cols' columns. */ if (i >= (chipcount / cols + 1)) {