mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
126 lines
4.0 KiB
Diff
126 lines
4.0 KiB
Diff
From be24fc7113549d4f7d8b6fa2df298dfd36fb1dd4 Mon Sep 17 00:00:00 2001
|
|
From: Martine Lenders <mail@martine-lenders.eu>
|
|
Date: Thu, 12 May 2016 16:07:35 +0200
|
|
Subject: [PATCH 2/3] Fix warnings
|
|
|
|
---
|
|
libfixmath/fix16_str.c | 8 ++++----
|
|
libfixmath/uint32.c | 10 +++++-----
|
|
unittests/libfixmath-unittests.h | 18 ++++++++++++++++++
|
|
unittests/unittests.h | 18 ------------------
|
|
4 files changed, 27 insertions(+), 27 deletions(-)
|
|
create mode 100644 unittests/libfixmath-unittests.h
|
|
delete mode 100644 unittests/unittests.h
|
|
|
|
diff --git a/libfixmath/fix16_str.c b/libfixmath/fix16_str.c
|
|
index eff906f..2c02c21 100644
|
|
--- a/libfixmath/fix16_str.c
|
|
+++ b/libfixmath/fix16_str.c
|
|
@@ -59,7 +59,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 */
|
|
@@ -70,7 +70,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';
|
|
@@ -90,7 +90,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;
|
|
@@ -103,7 +103,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..c1adc4f 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/libfixmath-unittests.h b/unittests/libfixmath-unittests.h
|
|
new file mode 100644
|
|
index 0000000..bac57d2
|
|
--- /dev/null
|
|
+++ b/unittests/libfixmath-unittests.h
|
|
@@ -0,0 +1,18 @@
|
|
+#include <stdio.h>
|
|
+
|
|
+#define COMMENT(x) printf("\n----" x "----\n");
|
|
+#define STR(x) #x
|
|
+#define STR2(x) STR(x)
|
|
+#define TEST(x) \
|
|
+ if (!(x)) { \
|
|
+ fflush(stdout); \
|
|
+ fflush(stderr); \
|
|
+ fprintf(stderr, "\033[31;1mFAILED:\033[22;39m " __FILE__ ":" STR2(__LINE__) " " #x "\n"); \
|
|
+ status = 1; \
|
|
+ } else { \
|
|
+ fflush(stdout); \
|
|
+ fflush(stderr); \
|
|
+ printf("\033[32;1mOK:\033[22;39m " #x "\n"); \
|
|
+ }
|
|
+
|
|
+
|
|
diff --git a/unittests/unittests.h b/unittests/unittests.h
|
|
deleted file mode 100644
|
|
index bac57d2..0000000
|
|
--- a/unittests/unittests.h
|
|
+++ /dev/null
|
|
@@ -1,18 +0,0 @@
|
|
-#include <stdio.h>
|
|
-
|
|
-#define COMMENT(x) printf("\n----" x "----\n");
|
|
-#define STR(x) #x
|
|
-#define STR2(x) STR(x)
|
|
-#define TEST(x) \
|
|
- if (!(x)) { \
|
|
- fflush(stdout); \
|
|
- fflush(stderr); \
|
|
- fprintf(stderr, "\033[31;1mFAILED:\033[22;39m " __FILE__ ":" STR2(__LINE__) " " #x "\n"); \
|
|
- status = 1; \
|
|
- } else { \
|
|
- fflush(stdout); \
|
|
- fflush(stderr); \
|
|
- printf("\033[32;1mOK:\033[22;39m " #x "\n"); \
|
|
- }
|
|
-
|
|
-
|
|
--
|
|
2.7.4
|
|
|