Blame view

RIOT/pkg/libfixmath/patches/0002-Fix-warnings.patch 4 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  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