Bläddra i källkod

compile with -Wextra

Thomas Buck 1 år sedan
förälder
incheckning
5d3ff84866
4 ändrade filer med 7 tillägg och 6 borttagningar
  1. 1
    0
      firmware/CMakeLists.txt
  2. 1
    1
      firmware/src/console.c
  3. 1
    1
      firmware/src/debug.c
  4. 4
    4
      firmware/src/log.c

+ 1
- 0
firmware/CMakeLists.txt Visa fil

@@ -58,6 +58,7 @@ target_include_directories(trackball PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/fatfs)
58 58
 
59 59
 target_compile_options(trackball PUBLIC
60 60
     -Wall
61
+    -Wextra
61 62
     -Werror
62 63
 )
63 64
 

+ 1
- 1
firmware/src/console.c Visa fil

@@ -163,7 +163,7 @@ void cnsl_init(void) {
163 163
 }
164 164
 
165 165
 static int32_t cnsl_find_line_end(void) {
166
-    for (int32_t i = 0; i < cnsl_buff_pos; i++) {
166
+    for (uint32_t i = 0; i < cnsl_buff_pos; i++) {
167 167
         if ((cnsl_line_buff[i] == '\r') || (cnsl_line_buff[i] == '\n')) {
168 168
             return i;
169 169
         }

+ 1
- 1
firmware/src/debug.c Visa fil

@@ -91,7 +91,7 @@ static void debug_msc_pmw3360_frame(void) {
91 91
     } else {
92 92
         UINT bw;
93 93
         res = f_write(&file, frame, r, &bw);
94
-        if ((res != FR_OK) || (bw != r)) {
94
+        if ((res != FR_OK) || ((ssize_t)bw != r)) {
95 95
             debug("error: f_write returned %d", res);
96 96
         }
97 97
     }

+ 4
- 4
firmware/src/log.c Visa fil

@@ -38,7 +38,7 @@ void log_dump_to_usb(void) {
38 38
 
39 39
     char buff[32];
40 40
     int l = snprintf(buff, sizeof(buff), "\r\n\r\nbuffered log output:\r\n");
41
-    if ((l > 0) && (l <= sizeof(buff))) {
41
+    if ((l > 0) && (l <= (int)sizeof(buff))) {
42 42
         usb_cdc_write(buff, l);
43 43
     }
44 44
 
@@ -50,7 +50,7 @@ void log_dump_to_usb(void) {
50 50
     }
51 51
 
52 52
     l = snprintf(buff, sizeof(buff), "\r\n\r\nlive log:\r\n");
53
-    if ((l > 0) && (l <= sizeof(buff))) {
53
+    if ((l > 0) && (l <= (int)sizeof(buff))) {
54 54
         usb_cdc_write(buff, l);
55 55
     }
56 56
 }
@@ -94,7 +94,7 @@ static int format_debug_log(char *buff, size_t len, const char *format, va_list
94 94
     if (l < 0) {
95 95
         // encoding error
96 96
         l = snprintf(buff, len, "%s: encoding error\r\n", __func__);
97
-    } else if (l >= len) {
97
+    } else if (l >= (ssize_t)len) {
98 98
         // not enough space for string
99 99
         l = snprintf(buff, len, "%s: message too long (%d)\r\n", __func__, l);
100 100
     }
@@ -110,7 +110,7 @@ void debug_log(bool log, const char* format, ...) {
110 110
     int l = format_debug_log(line_buff, sizeof(line_buff), format, args);
111 111
     va_end(args);
112 112
 
113
-    if ((l > 0) && (l <= sizeof(line_buff))) {
113
+    if ((l > 0) && (l <= (int)sizeof(line_buff))) {
114 114
         usb_cdc_write(line_buff, l);
115 115
 
116 116
         if (log) {

Laddar…
Avbryt
Spara