[flashrom] [PATCH] Modify strnlen() check for old OSes to check its presence directly

Andrey Korolyov andrey at xdel.ru
Sun Jan 3 20:22:19 CET 2016


Adding generic check against the function in addition to check for
a problematic compiler.

Fixes: r1878: Make strnlen() visible in old versions of glibc.

Signed-off-by: Andrey Korolyov <andrey at xdel.ru>
---
 flash.h   | 2 +-
 helpers.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/flash.h b/flash.h
index 24861ba..3af4c43 100644
--- a/flash.h
+++ b/flash.h
@@ -260,7 +260,7 @@ void tolower_string(char *str);
 #ifdef __MINGW32__
 char* strtok_r(char *str, const char *delim, char **nextp);
 #endif
-#if defined(__DJGPP__)
+#if defined(__DJGPP__) || ! defined(HAVE_STRNLEN)
 size_t strnlen(const char *str, size_t n);
 #endif
 
diff --git a/helpers.c b/helpers.c
index 7a146c3..cdc87e0 100644
--- a/helpers.c
+++ b/helpers.c
@@ -92,7 +92,7 @@ char* strtok_r(char *str, const char *delim, char **nextp)
 #endif
 
 /* There is no strnlen in DJGPP */
-#if defined(__DJGPP__)
+#if defined(__DJGPP__) || ! defined(HAVE_STRNLEN)
 size_t strnlen(const char *str, size_t n)
 {
 	size_t i;
-- 
1.8.4.5





More information about the flashrom mailing list