Hello Nico Huber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/19198
to review the following change.
Change subject: Fix linking with libpayload ......................................................................
Fix linking with libpayload
o flashbuses_to_text() is a cli function and should actually be moved or not be called from flashrom.c. o I couldn't find any libc that defines HAVE_STRNLEN.
Change-Id: I24349b4c06b30eeb89062f164ec0377463cfc5bc Signed-off-by: Nico Huber nico.huber@secunet.com --- M flash.h M flashrom.c M helpers.c 3 files changed, 8 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/98/19198/1
diff --git a/flash.h b/flash.h index 05cb59b..765ae4f 100644 --- a/flash.h +++ b/flash.h @@ -262,7 +262,7 @@ #ifdef __MINGW32__ char* strtok_r(char *str, const char *delim, char **nextp); #endif -#if defined(__DJGPP__) || !defined(HAVE_STRNLEN) +#if defined(__DJGPP__) size_t strnlen(const char *str, size_t n); #endif
diff --git a/flashrom.c b/flashrom.c index 2d73163..5a156ea 100644 --- a/flashrom.c +++ b/flashrom.c @@ -1166,7 +1166,7 @@ { const struct flashchip *chip; enum chipbustype buses_common; - char *tmp; + char *tmp = NULL;
for (chip = flashchips + startchip; chip && chip->name; chip++) { if (chip_to_probe && strcmp(chip->name, chip_to_probe) != 0) @@ -1248,9 +1248,12 @@ return -1;
+#ifndef __LIBPAYLOAD__ tmp = flashbuses_to_text(flash->chip->bustype); - msg_cinfo("%s %s flash chip "%s" (%d kB, %s) ", force ? "Assuming" : "Found", - flash->chip->vendor, flash->chip->name, flash->chip->total_size, tmp); +#endif + msg_cinfo("%s %s flash chip "%s" (%d kB%s%s) ", force ? "Assuming" : "Found", + flash->chip->vendor, flash->chip->name, flash->chip->total_size, + tmp ? ", " : "", tmp ? tmp : ""); free(tmp); #if CONFIG_INTERNAL == 1 if (programmer_table[programmer].map_flash_region == physmap) diff --git a/helpers.c b/helpers.c index f6eae46..7a146c3 100644 --- a/helpers.c +++ b/helpers.c @@ -92,7 +92,7 @@ #endif
/* There is no strnlen in DJGPP */ -#if defined(__DJGPP__) || !defined(HAVE_STRNLEN) +#if defined(__DJGPP__) size_t strnlen(const char *str, size_t n) { size_t i;