diff options
author | Alex Auvolat <alex@adnab.me> | 2016-07-14 11:45:11 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2016-07-14 11:45:11 +0200 |
commit | 2f13288a23da4dfaf6c40e1e943f83d8fa43145a (patch) | |
tree | 3b550ad22a00676470ceb2815afd21f42dfd8aae /src/common/libc | |
parent | 477911553e0443fcafad5bd96c97314aa2f8d9ea (diff) | |
download | kogata-2f13288a23da4dfaf6c40e1e943f83d8fa43145a.tar.gz kogata-2f13288a23da4dfaf6c40e1e943f83d8fa43145a.zip |
Fix sme warnings...
Diffstat (limited to 'src/common/libc')
-rw-r--r-- | src/common/libc/printf.c | 13 | ||||
-rw-r--r-- | src/common/libc/string.c | 12 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/common/libc/printf.c b/src/common/libc/printf.c index 68e08d8..8618741 100644 --- a/src/common/libc/printf.c +++ b/src/common/libc/printf.c @@ -69,10 +69,9 @@ int vsnprintf(char *buff, size_t len, const char* format, va_list ap){ } case 'x': { unsigned int hexa = va_arg(ap,int); - unsigned int nb; - int j, had_nonzero = 0; - for(j = 0; j < 8; j++) { - nb = (unsigned int)(hexa << (j*4)); + int had_nonzero = 0; + for(int j = 0; j < 8; j++) { + unsigned int nb = (unsigned int)(hexa << (j*4)); nb = (nb >> 28) & 0xf; // Skip the leading zeros if (nb == 0) { @@ -92,10 +91,8 @@ int vsnprintf(char *buff, size_t len, const char* format, va_list ap){ } case 'p': { unsigned int hexa = va_arg(ap,int); - unsigned int nb; - int j; - for (j = 0; j < 8; j++) { - nb = (unsigned int)(hexa << (j*4)); + for (int j = 0; j < 8; j++) { + unsigned int nb = (unsigned int)(hexa << (j*4)); nb = (nb >> 28) & 0xf; if (nb < 10) PUTCHAR('0'+nb); diff --git a/src/common/libc/string.c b/src/common/libc/string.c index 82c290f..d2a5f2f 100644 --- a/src/common/libc/string.c +++ b/src/common/libc/string.c @@ -107,9 +107,17 @@ int memcmp(const void *va, const void *vb, size_t count) { } void *memset(void *dest, int val, size_t count) { + uint8_t uval = (val & 0xFF); + uint32_t wval = (uval<<24)|(uval<<16)|(uval<<8)|uval; + + uint32_t *dest_w = (uint32_t*)dest; + for (size_t i = 0; i < count/4; i++) { + dest_w[i] = wval; + } + uint8_t *dest_c = (uint8_t*)dest; - for (size_t i = 0; i < count; i++) { - dest_c[i] = val; + for (size_t i = count - (count%4); i < count; i++) { + dest_c[i] = uval; } return dest; } |