Run clang-format on new sources from OpenBSD and make them 'checkpatch clean': this involved one small change in strlcpy.c to move an assignment outside of a conditional.
Replace the OpenBSD 'DEF_WEAK' macro invocations with 'weak_alias', as per other library code. Change-Id: Ifc3520f5f486a144de26329b4fe45c700b755047 Signed-off-by: Dan Cross <[email protected]> --- .../glibc-2.19-akaros/sysdeps/akaros/reallocarray.c | 9 ++++----- .../gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/strlcat.c | 11 +++++------ .../gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/strlcpy.c | 14 +++++++------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/reallocarray.c b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/reallocarray.c index baea252..817c310 100644 --- a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/reallocarray.c +++ b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/reallocarray.c @@ -15,19 +15,18 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/types.h> #include <errno.h> #include <stdint.h> #include <stdlib.h> +#include <sys/types.h> /* * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW */ -#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) +#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) -void * -reallocarray(void *optr, size_t nmemb, size_t size) +void *__reallocarray(void *optr, size_t nmemb, size_t size) { if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && nmemb > 0 && SIZE_MAX / nmemb < size) { @@ -36,4 +35,4 @@ reallocarray(void *optr, size_t nmemb, size_t size) } return realloc(optr, size * nmemb); } -DEF_WEAK(reallocarray); +weak_alias(__reallocarray, reallocarray) diff --git a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/strlcat.c b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/strlcat.c index 073b0d4..5e4b304 100644 --- a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/strlcat.c +++ b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/strlcat.c @@ -16,8 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/types.h> #include <string.h> +#include <sys/types.h> /* * Appends src to string dst of size dsize (unlike strncat, dsize is the @@ -26,8 +26,7 @@ * Returns strlen(src) + MIN(dsize, strlen(initial dst)). * If retval >= dsize, truncation occurred. */ -size_t -strlcat(char *dst, const char *src, size_t dsize) +size_t __strlcat(char *dst, const char *src, size_t dsize) { const char *odst = dst; const char *osrc = src; @@ -41,7 +40,7 @@ strlcat(char *dst, const char *src, size_t dsize) n = dsize - dlen; if (n-- == 0) - return(dlen + strlen(src)); + return (dlen + strlen(src)); while (*src != '\0') { if (n != 0) { *dst++ = *src; @@ -51,6 +50,6 @@ strlcat(char *dst, const char *src, size_t dsize) } *dst = '\0'; - return(dlen + (src - osrc)); /* count does not include NUL */ + return (dlen + (src - osrc)); /* count does not include NUL */ } -DEF_WEAK(strlcat); +weak_alias(__strlcat, strlcat) diff --git a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/strlcpy.c b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/strlcpy.c index 5fcf084..a7f50f4 100644 --- a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/strlcpy.c +++ b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/strlcpy.c @@ -16,16 +16,15 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/types.h> #include <string.h> +#include <sys/types.h> /* * Copy string src to buffer dst of size dsize. At most dsize-1 * chars will be copied. Always NUL terminates (unless dsize == 0). * Returns strlen(src); if retval >= dsize, truncation occurred. */ -size_t -strlcpy(char *dst, const char *src, size_t dsize) +size_t __strlcpy(char *dst, const char *src, size_t dsize) { const char *osrc = src; size_t nleft = dsize; @@ -33,7 +32,8 @@ strlcpy(char *dst, const char *src, size_t dsize) /* Copy as many bytes as will fit. */ if (nleft != 0) { while (--nleft != 0) { - if ((*dst++ = *src++) == '\0') + *dst++ = *src; + if (*src++ == '\0') break; } } @@ -41,11 +41,11 @@ strlcpy(char *dst, const char *src, size_t dsize) /* Not enough room in dst, add NUL and traverse rest of src. */ if (nleft == 0) { if (dsize != 0) - *dst = '\0'; /* NUL-terminate dst */ + *dst = '\0'; /* NUL-terminate dst */ while (*src++) ; } - return(src - osrc - 1); /* count does not include NUL */ + return (src - osrc - 1); /* count does not include NUL */ } -DEF_WEAK(strlcpy); +weak_alias(__strlcpy, strlcpy) -- 2.8.0.rc3.226.g39d4020 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
