From: Nathael Pajani Date: Thu, 24 Apr 2014 02:29:40 +0000 (+0200) Subject: No functional change. Only use the same coding rules as the other files. X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=f99b2790f0390f33d2111a2753ceee37ec95d40d;p=soft%2Flpc122x%2Fcore No functional change. Only use the same coding rules as the other files. --- diff --git a/lib/string.c b/lib/string.c index 1fd7ace..c72b309 100644 --- a/lib/string.c +++ b/lib/string.c @@ -32,9 +32,9 @@ * You should not use this function to access IO space, use memcpy_toio() * or memcpy_fromio() instead. */ -void * memcpy(void *dest, const void *src, size_t count) +void* memcpy(void* dest, const void* src, size_t count) { - unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src; + unsigned long* dl = (unsigned long*)dest, *sl = (unsigned long*)src; char *d8, *s8; if (src == dest) @@ -50,9 +50,9 @@ void * memcpy(void *dest, const void *src, size_t count) /* copy the reset one byte at a time */ d8 = (char *)dl; s8 = (char *)sl; - while (count--) + while (count--) { *d8++ = *s8++; - + } return dest; } @@ -64,11 +64,11 @@ void * memcpy(void *dest, const void *src, size_t count) * * Do not use memset() to access IO space, use memset_io() instead. */ -void * memset(void * s,int c,size_t count) +void* memset(void* s, int c, size_t count) { - unsigned long *sl = (unsigned long *) s; + unsigned long* sl = (unsigned long*) s; unsigned long cl = 0; - char *s8; + char* s8; int i; /* do it one word at a time (32 bits or 64 bits) while possible */ @@ -83,10 +83,10 @@ void * memset(void * s,int c,size_t count) } } /* fill 8 bits at a time */ - s8 = (char *)sl; - while (count--) + s8 = (char*)sl; + while (count--) { *s8++ = c; - + } return s; } @@ -95,12 +95,13 @@ void * memset(void * s,int c,size_t count) * @dest: Where to copy the string to * @src: Where to copy the string from */ -char * strcpy(char * dest,const char *src) +char* strcpy(char* dest, const char* src) { - char *tmp = dest; + char* tmp = dest; - while ((*dest++ = *src++) != '\0') + while ((*dest++ = *src++) != '\0') { /* nothing */; + } return tmp; } @@ -114,13 +115,13 @@ char * strcpy(char * dest,const char *src) * However, the result is not %NUL-terminated if the source exceeds * @count bytes. */ -char * strncpy(char * dest,const char *src,size_t count) +char* strncpy(char* dest, const char* src, size_t count) { - char *tmp = dest; + char* tmp = dest; - while (count-- && (*dest++ = *src++) != '\0') + while (count-- && (*dest++ = *src++) != '\0') { /* nothing */; - + } return tmp; } @@ -129,15 +130,15 @@ char * strncpy(char * dest,const char *src,size_t count) * @cs: One string * @ct: Another string */ -int strcmp(const char * cs,const char * ct) +int strcmp(const char* cs, const char* ct) { register signed char __res; while (1) { - if ((__res = *cs - *ct++) != 0 || !*cs++) + if ((__res = *cs - *ct++) != 0 || !*cs++) { break; + } } - return __res; } @@ -147,13 +148,14 @@ int strcmp(const char * cs,const char * ct) * @ct: Another string * @count: The maximum number of bytes to compare */ -int strncmp(const char * cs,const char * ct,size_t count) +int strncmp(const char* cs, const char* ct, size_t count) { register signed char __res = 0; while (count) { - if ((__res = *cs - *ct++) != 0 || !*cs++) + if ((__res = *cs - *ct++) != 0 || !*cs++) { break; + } count--; } @@ -165,11 +167,13 @@ int strncmp(const char * cs,const char * ct,size_t count) * @s: The string to be searched * @c: The character to search for */ -char * strchr(const char * s, int c) +char* strchr(const char* s, int c) { - for(; *s != (char) c; ++s) - if (*s == '\0') + for(; *s != (char) c; ++s) { + if (*s == '\0') { return NULL; + } + } return (char *) s; } @@ -177,12 +181,13 @@ char * strchr(const char * s, int c) * strlen - Find the length of a string * @s: The string to be sized */ -size_t strlen(const char * s) +size_t strlen(const char* s) { - const char *sc; + const char* sc; - for (sc = s; *sc != '\0'; ++sc) + for (sc = s; *sc != '\0'; ++sc) { /* nothing */; + } return sc - s; } @@ -191,14 +196,15 @@ size_t strlen(const char * s) * @s: The string to be searched * @c: The character to search for */ -char * strrchr(const char * s, int c) +char* strrchr(const char* s, int c) { - const char *p = s + strlen(s); - do { - if (*p == (char)c) - return (char *)p; - } while (--p >= s); - return NULL; + const char* p = s + strlen(s); + do { + if (*p == (char)c) { + return (char *)p; + } + } while (--p >= s); + return NULL; } /** @@ -206,11 +212,12 @@ char * strrchr(const char * s, int c) * @s: The string to be sized * @count: The maximum number of bytes to search */ -size_t strnlen(const char * s, size_t count) +size_t strnlen(const char* s, size_t count) { - const char *sc; + const char* sc; - for (sc = s; count-- && *sc != '\0'; ++sc) + for (sc = s; count-- && *sc != '\0'; ++sc) { /* nothing */; + } return sc - s; }