Elyes Haouas has submitted this change. ( https://review.coreboot.org/c/coreboot/+/83223?usp=email )
Change subject: lib/string: change return types to match C standard ......................................................................
lib/string: change return types to match C standard
The return type of strspn and strcspn is supposed to be a size_t and not a signed integer.
TEST=Now the openSIL code can be built with the coreboot headers without needing to add '-Wno-builtin-declaration-mismatch' or '-Wno-incompatible-library-redeclaration' to the cflags. Before the build would error out with various 'mismatch in return type of built-in function' errors.
Signed-off-by: Felix Held felix-coreboot@felixheld.de Change-Id: I0ff612e2eee4f556f5c572b02cbc600ca411ae20 Reviewed-on: https://review.coreboot.org/c/coreboot/+/83223 Reviewed-by: Marshall Dawson marshalldawson3rd@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Elyes Haouas ehaouas@noos.fr Reviewed-by: Varshit Pandya pandyavarshit@gmail.com Reviewed-by: Matt DeVillier matt.devillier@gmail.com --- M src/include/string.h M src/lib/string.c 2 files changed, 6 insertions(+), 6 deletions(-)
Approvals: Elyes Haouas: Looks good to me, approved Matt DeVillier: Looks good to me, approved build bot (Jenkins): Verified Varshit Pandya: Looks good to me, but someone else must approve Marshall Dawson: Looks good to me, approved
diff --git a/src/include/string.h b/src/include/string.h index dc301ea..30d014a 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -20,8 +20,8 @@ char *strcpy(char *dst, const char *src); int strcmp(const char *s1, const char *s2); int strncmp(const char *s1, const char *s2, size_t maxlen); -int strspn(const char *str, const char *spn); -int strcspn(const char *str, const char *spn); +size_t strspn(const char *str, const char *spn); +size_t strcspn(const char *str, const char *spn); char *strstr(const char *haystack, const char *needle); char *strtok_r(char *str, const char *delim, char **ptr); char *strtok(char *str, const char *delim); diff --git a/src/lib/string.c b/src/lib/string.c index 7553295..b1996ff 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -125,9 +125,9 @@ return 0; }
-int strspn(const char *str, const char *spn) +size_t strspn(const char *str, const char *spn) { - int ret = 0; + size_t ret = 0;
while (*str != 0) { const char *p; @@ -140,9 +140,9 @@ return ret; }
-int strcspn(const char *str, const char *spn) +size_t strcspn(const char *str, const char *spn) { - int ret = 0; + size_t ret = 0;
while (*str != 0) { const char *p;