Nico Huber merged this change.
Fix linking with libpayload
o Move flashbuses_to_text() to flashrom.c, it's not a cli function.
o Guard `!defined(HAVE_STRNLEN)`. This guard was introduced in
23e10b87 (Add a bunch of new/tested stuff and various small
changes 24) to support older BSDs. It's probably completely
broken because HAVE_STRNLEN is presumably a GNU autotools
thing. But we can't fix it without retesting these older BSDs.
Change-Id: I561135209b819361d125eeaeef9ff886d6bae987
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/18738
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M cli_common.c
M flash.h
M flashrom.c
M helpers.c
4 files changed, 36 insertions(+), 37 deletions(-)
diff --git a/cli_common.c b/cli_common.c
index 71cc2dd..256f1fa 100644
--- a/cli_common.c
+++ b/cli_common.c
@@ -24,40 +24,6 @@
#include <string.h>
#include "flash.h"
-/*
- * Return a string corresponding to the bustype parameter.
- * Memory is obtained with malloc() and must be freed with free() by the caller.
- */
-char *flashbuses_to_text(enum chipbustype bustype)
-{
- char *ret = calloc(1, 1);
- /*
- * FIXME: Once all chipsets and flash chips have been updated, NONSPI
- * will cease to exist and should be eliminated here as well.
- */
- if (bustype == BUS_NONSPI) {
- ret = strcat_realloc(ret, "Non-SPI, ");
- } else {
- if (bustype & BUS_PARALLEL)
- ret = strcat_realloc(ret, "Parallel, ");
- if (bustype & BUS_LPC)
- ret = strcat_realloc(ret, "LPC, ");
- if (bustype & BUS_FWH)
- ret = strcat_realloc(ret, "FWH, ");
- if (bustype & BUS_SPI)
- ret = strcat_realloc(ret, "SPI, ");
- if (bustype & BUS_PROG)
- ret = strcat_realloc(ret, "Programmer-specific, ");
- if (bustype == BUS_NONE)
- ret = strcat_realloc(ret, "None, ");
- }
- /* Kill last comma. */
- ret[strlen(ret) - 2] = '\0';
- ret = realloc(ret, strlen(ret) + 1);
- return ret;
-}
-
-
void print_chip_support_status(const struct flashchip *chip)
{
if (chip->feature_bits & FEATURE_OTP) {
diff --git a/flash.h b/flash.h
index 47c32f4..b5eb99b 100644
--- a/flash.h
+++ b/flash.h
@@ -264,13 +264,14 @@
#ifdef __MINGW32__
char* strtok_r(char *str, const char *delim, char **nextp);
#endif
-#if defined(__DJGPP__) || !defined(HAVE_STRNLEN)
+#if defined(__DJGPP__) || (!defined(__LIBPAYLOAD__) && !defined(HAVE_STRNLEN))
size_t strnlen(const char *str, size_t n);
#endif
/* flashrom.c */
extern const char flashrom_version[];
extern const char *chip_to_probe;
+char *flashbuses_to_text(enum chipbustype bustype);
int map_flash(struct flashctx *flash);
void unmap_flash(struct flashctx *flash);
int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
@@ -308,7 +309,6 @@
#define ERROR_FLASHROM_LIMIT -201
/* cli_common.c */
-char *flashbuses_to_text(enum chipbustype bustype);
void print_chip_support_status(const struct flashchip *chip);
/* cli_output.c */
diff --git a/flashrom.c b/flashrom.c
index 838dfd0..379f75e 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1163,6 +1163,39 @@
return 0;
}
+/*
+ * Return a string corresponding to the bustype parameter.
+ * Memory is obtained with malloc() and must be freed with free() by the caller.
+ */
+char *flashbuses_to_text(enum chipbustype bustype)
+{
+ char *ret = calloc(1, 1);
+ /*
+ * FIXME: Once all chipsets and flash chips have been updated, NONSPI
+ * will cease to exist and should be eliminated here as well.
+ */
+ if (bustype == BUS_NONSPI) {
+ ret = strcat_realloc(ret, "Non-SPI, ");
+ } else {
+ if (bustype & BUS_PARALLEL)
+ ret = strcat_realloc(ret, "Parallel, ");
+ if (bustype & BUS_LPC)
+ ret = strcat_realloc(ret, "LPC, ");
+ if (bustype & BUS_FWH)
+ ret = strcat_realloc(ret, "FWH, ");
+ if (bustype & BUS_SPI)
+ ret = strcat_realloc(ret, "SPI, ");
+ if (bustype & BUS_PROG)
+ ret = strcat_realloc(ret, "Programmer-specific, ");
+ if (bustype == BUS_NONE)
+ ret = strcat_realloc(ret, "None, ");
+ }
+ /* Kill last comma. */
+ ret[strlen(ret) - 2] = '\0';
+ ret = realloc(ret, strlen(ret) + 1);
+ return ret;
+}
+
int probe_flash(struct registered_master *mst, int startchip, struct flashctx *flash, int force)
{
const struct flashchip *chip;
diff --git a/helpers.c b/helpers.c
index f6eae46..8bc808a 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__) || (!defined(__LIBPAYLOAD__) && !defined(HAVE_STRNLEN))
size_t strnlen(const char *str, size_t n)
{
size_t i;
To view, visit change 18738. To unsubscribe, visit settings.