[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] fdt_ro.c: implement strnlen
From: |
John Arbuckle |
Subject: |
[Qemu-devel] [PATCH] fdt_ro.c: implement strnlen |
Date: |
Wed, 18 Oct 2017 18:31:16 -0400 |
Implement the strnlen() function if it isn't implemented.
Signed-off-by: John Arbuckle <address@hidden>
---
libfdt/fdt_ro.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 3d00d2e..a7986fb 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -55,6 +55,30 @@
#include "libfdt_internal.h"
+/* if the current environment does not define strnlen */
+#ifndef strnlen
+
+/* This eliminates the missing prototype warning */
+int strnlen(const char *string, int max_count);
+
+/*
+ * strnlen: return the length of a string or max_count
+ * which ever is shortest
+ */
+
+int strnlen(const char *string, int max_count)
+{
+ int count;
+ for(count = 0; count < max_count; count++) {
+ if (string[count] == '\0') {
+ break;
+ }
+ }
+ return count;
+}
+
+#endif /* strnlen */
+
static int _fdt_nodename_eq(const void *fdt, int offset,
const char *s, int len)
{
--
2.13.5 (Apple Git-94)
- [Qemu-devel] [PATCH] fdt_ro.c: implement strnlen,
John Arbuckle <=