From b9b3409270387c7edf6df440cb3e1ad00e6205e6 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 12 May 2016 16:07:35 +0200 Subject: [PATCH 1/2] Fix warnings --- libfixmath/fix16_str.c | 8 ++++---- libfixmath/uint32.c | 10 +++++----- unittests/{unittests.h => libfixmath-unittests.h} | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) rename unittests/{unittests.h => libfixmath-unittests.h} (99%) diff --git a/libfixmath/fix16_str.c b/libfixmath/fix16_str.c index 07df864..f533907 100644 --- a/libfixmath/fix16_str.c +++ b/libfixmath/fix16_str.c @@ -71,7 +71,7 @@ void fix16_to_str(fix16_t value, char *buf, int decimals) fix16_t fix16_from_str(const char *buf) { - while (isspace(*buf)) + while (isspace((unsigned char) *buf)) buf++; /* Decode the sign */ @@ -82,7 +82,7 @@ fix16_t fix16_from_str(const char *buf) /* Decode the integer part */ uint32_t intpart = 0; int count = 0; - while (isdigit(*buf)) + while (isdigit((unsigned char) *buf)) { intpart *= 10; intpart += *buf++ - '0'; @@ -102,7 +102,7 @@ fix16_t fix16_from_str(const char *buf) uint32_t fracpart = 0; uint32_t scale = 1; - while (isdigit(*buf) && scale < 100000) + while (isdigit((unsigned char) *buf) && scale < 100000) { scale *= 10; fracpart *= 10; @@ -115,7 +115,7 @@ fix16_t fix16_from_str(const char *buf) /* Verify that there is no garbage left over */ while (*buf != '\0') { - if (!isdigit(*buf) && !isspace(*buf)) + if (!isdigit((unsigned char) *buf) && !isspace((unsigned char) *buf)) return fix16_overflow; buf++; diff --git a/libfixmath/uint32.c b/libfixmath/uint32.c index 2980ab9..855774d 100644 --- a/libfixmath/uint32.c +++ b/libfixmath/uint32.c @@ -6,10 +6,10 @@ uint32_t uint32_log2(uint32_t inVal) { if(inVal == 0) return 0; uint32_t tempOut = 0; - if(inVal >= (1 << 16)) { inVal >>= 16; tempOut += 16; } - if(inVal >= (1 << 8)) { inVal >>= 8; tempOut += 8; } - if(inVal >= (1 << 4)) { inVal >>= 4; tempOut += 4; } - if(inVal >= (1 << 2)) { inVal >>= 2; tempOut += 2; } - if(inVal >= (1 << 1)) { tempOut += 1; } + if(inVal >= ((uint32_t) 1 << 16)) { inVal >>= 16; tempOut += 16; } + if(inVal >= ((uint32_t) 1 << 8)) { inVal >>= 8; tempOut += 8; } + if(inVal >= ((uint32_t) 1 << 4)) { inVal >>= 4; tempOut += 4; } + if(inVal >= ((uint32_t) 1 << 2)) { inVal >>= 2; tempOut += 2; } + if(inVal >= ((uint32_t) 1 << 1)) { tempOut += 1; } return tempOut; } diff --git a/unittests/unittests.h b/unittests/libfixmath-unittests.h similarity index 99% rename from unittests/unittests.h rename to unittests/libfixmath-unittests.h index bac57d2..57ad8f8 100644 --- a/unittests/unittests.h +++ b/unittests/libfixmath-unittests.h @@ -15,4 +15,3 @@ printf("\033[32;1mOK:\033[22;39m " #x "\n"); \ } - -- 2.27.0