oslib: make str* compat functions more uniform
authorSitsofe Wheeler <sitsofe@yahoo.com>
Tue, 20 Mar 2018 10:46:32 +0000 (10:46 +0000)
committerSitsofe Wheeler <sitsofe@yahoo.com>
Wed, 21 Mar 2018 22:09:28 +0000 (22:09 +0000)
- 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>
oslib/strcasestr.c
oslib/strcasestr.h
oslib/strlcat.c
oslib/strlcat.h
oslib/strndup.c
oslib/strndup.h
oslib/strsep.c
oslib/strsep.h

index 262660911cdfbb96c7cc43135f0d7d1fcf290ff7..5fa05fa1404ac1daa2f9d7e9be70962e9587eb35 100644 (file)
@@ -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)
 {
index 43d61df4daaca2d938cf50df8b3a57911001f38a..f13e929dddc9e21113bea493bf5d35f054e969cd 100644 (file)
@@ -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
index 3b33d0eb56a72e64e87ecc79b8a3334381bd39fe..6c4c67863256891f15b40b47b1969db1ab8ee37e 100644 (file)
@@ -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
index 720034fe72d5dbf8411ec6edc7d69e98853f0834..f76639276f8d757837341ec2f60bcf4e55f992af 100644 (file)
@@ -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
index 40e92f820d12b1279e35a94739dde78f16746fa6..657904ab64d8044f71cce87b716743a21036186a 100644 (file)
@@ -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);
index 2cb904dab0b76448c59172f80084b9a96075d023..2f41848ec2d54f5f821050a444239a6d60cb19c5 100644 (file)
@@ -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
index b71e9f7bf25ab34e17084b737af5ecccd2a0f85a..2d42ca0f31e7eb1535d78e092507320b7160cf71 100644 (file)
@@ -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
index 5fea5d191f3dc7122bb9446b22851a355c108bca..8cd9ada997f2172eb6625066357d94df3e13a89e 100644 (file)
@@ -1,6 +1,10 @@
+#ifndef CONFIG_STRSEP
+
 #ifndef FIO_STRSEP_LIB_H
 #define FIO_STRSEP_LIB_H
 
 char *strsep(char **, const char *);
 
 #endif
+
+#endif