summaryrefslogtreecommitdiff
path: root/oslib
diff options
context:
space:
mode:
authorSitsofe Wheeler <sitsofe@yahoo.com>2018-03-20 10:46:32 +0000
committerSitsofe Wheeler <sitsofe@yahoo.com>2018-03-21 22:09:28 +0000
commit5d413e0897fee7c2bf10d9ecc0860d3b399d66d5 (patch)
tree8025d7fe9c6d4cc874830b71db9d3817e149f253 /oslib
parent8393ca93334319f066ce6abb44d0f4b4921abbe1 (diff)
oslib: make str* compat functions more uniform
- Ensure there are CONFIG_ guards in the headers and .c files because sometime utilities include oslib headers directly and reference oslib .c files in the Makefile - Ensure all the oslib/str*.h files have redefinition guards - Shuffle some #include lines from the .h files to the .c ones - Ensure the <name>.c files have #include "<name>.h" in them so the compiler can check the declaration and definition match Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
Diffstat (limited to 'oslib')
-rw-r--r--oslib/strcasestr.c5
-rw-r--r--oslib/strcasestr.h7
-rw-r--r--oslib/strlcat.c4
-rw-r--r--oslib/strlcat.h4
-rw-r--r--oslib/strndup.c6
-rw-r--r--oslib/strndup.h9
-rw-r--r--oslib/strsep.c7
-rw-r--r--oslib/strsep.h4
8 files changed, 33 insertions, 13 deletions
diff --git a/oslib/strcasestr.c b/oslib/strcasestr.c
index 2626609..5fa05fa 100644
--- a/oslib/strcasestr.c
+++ b/oslib/strcasestr.c
@@ -1,7 +1,8 @@
+#ifndef CONFIG_STRCASESTR
+
#include <ctype.h>
#include <stddef.h>
-
-#ifndef CONFIG_STRCASESTR
+#include "strcasestr.h"
char *strcasestr(const char *s1, const char *s2)
{
diff --git a/oslib/strcasestr.h b/oslib/strcasestr.h
index 43d61df..f13e929 100644
--- a/oslib/strcasestr.h
+++ b/oslib/strcasestr.h
@@ -1,8 +1,4 @@
-#ifdef CONFIG_STRCASESTR
-
-#include <string.h>
-
-#else
+#ifndef CONFIG_STRCASESTR
#ifndef FIO_STRCASESTR_H
#define FIO_STRCASESTR_H
@@ -10,4 +6,5 @@
char *strcasestr(const char *haystack, const char *needle);
#endif
+
#endif
diff --git a/oslib/strlcat.c b/oslib/strlcat.c
index 3b33d0e..6c4c678 100644
--- a/oslib/strlcat.c
+++ b/oslib/strlcat.c
@@ -1,3 +1,5 @@
+#ifndef CONFIG_STRLCAT
+
#include <string.h>
#include "strlcat.h"
@@ -22,3 +24,5 @@ size_t strlcat(char *dst, const char *src, size_t size)
return dstlen + srclen;
}
+
+#endif
diff --git a/oslib/strlcat.h b/oslib/strlcat.h
index 720034f..f766392 100644
--- a/oslib/strlcat.h
+++ b/oslib/strlcat.h
@@ -1,3 +1,5 @@
+#ifndef CONFIG_STRLCAT
+
#ifndef FIO_STRLCAT_H
#define FIO_STRLCAT_H
@@ -6,3 +8,5 @@
size_t strlcat(char *dst, const char *src, size_t size);
#endif
+
+#endif
diff --git a/oslib/strndup.c b/oslib/strndup.c
index 40e92f8..657904a 100644
--- a/oslib/strndup.c
+++ b/oslib/strndup.c
@@ -1,9 +1,9 @@
-#include <stdlib.h>
+#ifndef CONFIG_HAVE_STRNDUP
+#include <stdlib.h>
+#include <string.h>
#include "strndup.h"
-#ifndef CONFIG_HAVE_STRNDUP
-
char *strndup(const char *s, size_t n)
{
char *str = malloc(n + 1);
diff --git a/oslib/strndup.h b/oslib/strndup.h
index 2cb904d..2f41848 100644
--- a/oslib/strndup.h
+++ b/oslib/strndup.h
@@ -1,7 +1,12 @@
-#include <string.h>
-
#ifndef CONFIG_HAVE_STRNDUP
+#ifndef FIO_STRNDUP_LIB_H
+#define FIO_STRNDUP_LIB_H
+
+#include <stddef.h>
+
char *strndup(const char *s, size_t n);
#endif
+
+#endif
diff --git a/oslib/strsep.c b/oslib/strsep.c
index b71e9f7..2d42ca0 100644
--- a/oslib/strsep.c
+++ b/oslib/strsep.c
@@ -1,4 +1,7 @@
-#include <stdio.h>
+#ifndef CONFIG_STRSEP
+
+#include <stddef.h>
+#include "strsep.h"
char *strsep(char **stringp, const char *delim)
{
@@ -27,3 +30,5 @@ char *strsep(char **stringp, const char *delim)
} while (sc != 0);
} while (1);
}
+
+#endif
diff --git a/oslib/strsep.h b/oslib/strsep.h
index 5fea5d1..8cd9ada 100644
--- a/oslib/strsep.h
+++ b/oslib/strsep.h
@@ -1,6 +1,10 @@
+#ifndef CONFIG_STRSEP
+
#ifndef FIO_STRSEP_LIB_H
#define FIO_STRSEP_LIB_H
char *strsep(char **, const char *);
#endif
+
+#endif