Kaynağa Gözat

add -Wshadow

Thomas Buck 10 ay önce
ebeveyn
işleme
689a3189d7
4 değiştirilmiş dosya ile 56 ekleme ve 54 silme
  1. 2
    0
      CMakeLists.txt
  2. 24
    24
      src/console.c
  3. 10
    10
      src/log.c
  4. 20
    20
      src/workflow.c

+ 2
- 0
CMakeLists.txt Dosyayı Görüntüle

@@ -157,6 +157,7 @@ target_compile_options(gadget PUBLIC
157 157
     -Wall
158 158
     -Wextra
159 159
     -Werror
160
+    -Wshadow
160 161
 )
161 162
 
162 163
 # suppress some warnings for borked 3rd party files in Pico SDK
@@ -166,6 +167,7 @@ set_source_files_properties(pico-sdk/src/rp2_common/pico_cyw43_driver/cyw43_driv
166 167
 set_source_files_properties(pico-sdk/lib/btstack/src/classic/avdtp_util.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
167 168
 set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_client.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
168 169
 set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_server.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
170
+set_source_files_properties(pico-sdk/src/rp2_common/hardware_flash/flash.c PROPERTIES COMPILE_FLAGS -Wno-shadow)
169 171
 
170 172
 # pull in common dependencies
171 173
 target_link_libraries(gadget

+ 24
- 24
src/console.c Dosyayı Görüntüle

@@ -319,14 +319,14 @@ static void cnsl_interpret(const char *line) {
319 319
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
320 320
 #endif // TEST_VOLCANO_AUTO_CONNECT
321 321
 
322
-            int8_t r = volcano_set_target_temp(v);
322
+            int8_t t = volcano_set_target_temp(v);
323 323
 
324 324
 #ifdef TEST_VOLCANO_AUTO_CONNECT
325 325
             ble_disconnect();
326 326
 #endif // TEST_VOLCANO_AUTO_CONNECT
327 327
 
328
-            if (r < 0) {
329
-                println("error writing target temp %d", r);
328
+            if (t < 0) {
329
+                println("error writing target temp %d", t);
330 330
             } else {
331 331
                 println("success");
332 332
             }
@@ -341,14 +341,14 @@ static void cnsl_interpret(const char *line) {
341 341
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
342 342
 #endif // TEST_VOLCANO_AUTO_CONNECT
343 343
 
344
-            int8_t r = volcano_set_heater_state(val == 1);
344
+            int8_t t = volcano_set_heater_state(val == 1);
345 345
 
346 346
 #ifdef TEST_VOLCANO_AUTO_CONNECT
347 347
             ble_disconnect();
348 348
 #endif // TEST_VOLCANO_AUTO_CONNECT
349 349
 
350
-            if (r < 0) {
351
-                println("error writing heater state %d", r);
350
+            if (t < 0) {
351
+                println("error writing heater state %d", t);
352 352
             } else {
353 353
                 println("success");
354 354
             }
@@ -363,14 +363,14 @@ static void cnsl_interpret(const char *line) {
363 363
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
364 364
 #endif // TEST_VOLCANO_AUTO_CONNECT
365 365
 
366
-            int8_t r = volcano_set_pump_state(val == 1);
366
+            int8_t s = volcano_set_pump_state(val == 1);
367 367
 
368 368
 #ifdef TEST_VOLCANO_AUTO_CONNECT
369 369
             ble_disconnect();
370 370
 #endif // TEST_VOLCANO_AUTO_CONNECT
371 371
 
372
-            if (r < 0) {
373
-                println("error writing pump state %d", r);
372
+            if (s < 0) {
373
+                println("error writing pump state %d", s);
374 374
             } else {
375 375
                 println("success");
376 376
             }
@@ -385,14 +385,14 @@ static void cnsl_interpret(const char *line) {
385 385
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
386 386
 #endif // TEST_VOLCANO_AUTO_CONNECT
387 387
 
388
-            int8_t r = volcano_set_unit((val == 'C') ? UNIT_C : UNIT_F);
388
+            int8_t u = volcano_set_unit((val == 'C') ? UNIT_C : UNIT_F);
389 389
 
390 390
 #ifdef TEST_VOLCANO_AUTO_CONNECT
391 391
             ble_disconnect();
392 392
 #endif // TEST_VOLCANO_AUTO_CONNECT
393 393
 
394
-            if (r < 0) {
395
-                println("error writing value %d", r);
394
+            if (u < 0) {
395
+                println("error writing value %d", u);
396 396
             } else {
397 397
                 println("success");
398 398
             }
@@ -407,14 +407,14 @@ static void cnsl_interpret(const char *line) {
407 407
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
408 408
 #endif // TEST_VOLCANO_AUTO_CONNECT
409 409
 
410
-            int8_t r = volcano_set_vibration(val == 1);
410
+            int8_t v = volcano_set_vibration(val == 1);
411 411
 
412 412
 #ifdef TEST_VOLCANO_AUTO_CONNECT
413 413
             ble_disconnect();
414 414
 #endif // TEST_VOLCANO_AUTO_CONNECT
415 415
 
416
-            if (r < 0) {
417
-                println("error writing value %d", r);
416
+            if (v < 0) {
417
+                println("error writing value %d", v);
418 418
             } else {
419 419
                 println("success");
420 420
             }
@@ -429,14 +429,14 @@ static void cnsl_interpret(const char *line) {
429 429
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
430 430
 #endif // TEST_VOLCANO_AUTO_CONNECT
431 431
 
432
-            int8_t r = volcano_set_display_cooling(val == 1);
432
+            int8_t c = volcano_set_display_cooling(val == 1);
433 433
 
434 434
 #ifdef TEST_VOLCANO_AUTO_CONNECT
435 435
             ble_disconnect();
436 436
 #endif // TEST_VOLCANO_AUTO_CONNECT
437 437
 
438
-            if (r < 0) {
439
-                println("error writing value %d", r);
438
+            if (c < 0) {
439
+                println("error writing value %d", c);
440 440
             } else {
441 441
                 println("success");
442 442
             }
@@ -517,14 +517,14 @@ static void cnsl_interpret(const char *line) {
517 517
             DEV_AUTO_CONNECT(TEST_CRAFTY_AUTO_CONNECT);
518 518
 #endif // TEST_CRAFTY_AUTO_CONNECT
519 519
 
520
-            int8_t r = crafty_set_target_temp(v);
520
+            int8_t t = crafty_set_target_temp(v);
521 521
 
522 522
 #ifdef TEST_CRAFTY_AUTO_CONNECT
523 523
             ble_disconnect();
524 524
 #endif // TEST_CRAFTY_AUTO_CONNECT
525 525
 
526
-            if (r < 0) {
527
-                println("error writing target temp %d", r);
526
+            if (t < 0) {
527
+                println("error writing target temp %d", t);
528 528
             } else {
529 529
                 println("success");
530 530
             }
@@ -539,14 +539,14 @@ static void cnsl_interpret(const char *line) {
539 539
             DEV_AUTO_CONNECT(TEST_CRAFTY_AUTO_CONNECT);
540 540
 #endif // TEST_CRAFTY_AUTO_CONNECT
541 541
 
542
-            int8_t r = crafty_set_heater_state(val == 1);
542
+            int8_t s = crafty_set_heater_state(val == 1);
543 543
 
544 544
 #ifdef TEST_CRAFTY_AUTO_CONNECT
545 545
             ble_disconnect();
546 546
 #endif // TEST_CRAFTY_AUTO_CONNECT
547 547
 
548
-            if (r < 0) {
549
-                println("error writing heater state %d", r);
548
+            if (s < 0) {
549
+                println("error writing heater state %d", s);
550 550
             } else {
551 551
                 println("success");
552 552
             }

+ 10
- 10
src/log.c Dosyayı Görüntüle

@@ -30,7 +30,7 @@
30 30
 #include "log.h"
31 31
 
32 32
 static uint8_t log_buff[4096] = {0};
33
-static struct ring_buffer log = RB_INIT(log_buff, sizeof(log_buff), 1);
33
+static struct ring_buffer log_rb = RB_INIT(log_buff, sizeof(log_buff), 1);
34 34
 
35 35
 static uint8_t line_buff[256] = {0};
36 36
 static volatile bool got_input = false;
@@ -40,16 +40,16 @@ static FIL log_file_fat;
40 40
 #endif // PICOWOTA
41 41
 
42 42
 static void add_to_log(const void *buff, size_t len) {
43
-    rb_add(&log, buff, len);
43
+    rb_add(&log_rb, buff, len);
44 44
 }
45 45
 
46 46
 struct ring_buffer *log_get(void) {
47
-    return &log;
47
+    return &log_rb;
48 48
 }
49 49
 
50 50
 #ifndef PICOWOTA
51 51
 static void log_dump_to_x(void (*write)(const void *, size_t)) {
52
-    if (rb_len(&log) == 0) {
52
+    if (rb_len(&log_rb) == 0) {
53 53
         return;
54 54
     }
55 55
 
@@ -58,7 +58,7 @@ static void log_dump_to_x(void (*write)(const void *, size_t)) {
58 58
         write(line_buff, l);
59 59
     }
60 60
 
61
-    rb_dump(&log, write, 0);
61
+    rb_dump(&log_rb, write, 0);
62 62
 
63 63
     l = snprintf((char *)line_buff, sizeof(line_buff), "\r\n\r\nlive log:\r\n");
64 64
     if ((l > 0) && (l <= (int)sizeof(line_buff))) {
@@ -91,7 +91,7 @@ void log_dump_to_disk(void) {
91 91
         return;
92 92
     }
93 93
 
94
-    rb_dump(&log, log_file_write_callback, 0);
94
+    rb_dump(&log_rb, log_file_write_callback, 0);
95 95
 
96 96
     res = f_close(&log_file_fat);
97 97
     if (res != FR_OK) {
@@ -101,7 +101,7 @@ void log_dump_to_disk(void) {
101 101
 
102 102
 #endif // PICOWOTA
103 103
 
104
-void debug_log_va(bool log, const char *format, va_list args) {
104
+void debug_log_va(bool do_log, const char *format, va_list args) {
105 105
     int l = vsnprintf((char *)line_buff, sizeof(line_buff), format, args);
106 106
 
107 107
     if (l < 0) {
@@ -120,16 +120,16 @@ void debug_log_va(bool log, const char *format, va_list args) {
120 120
 #endif // NDEBUG
121 121
 #endif // PICOWOTA
122 122
 
123
-        if (log) {
123
+        if (do_log) {
124 124
             add_to_log(line_buff, l);
125 125
         }
126 126
     }
127 127
 }
128 128
 
129
-void debug_log(bool log, const char* format, ...) {
129
+void debug_log(bool do_log, const char* format, ...) {
130 130
     va_list args;
131 131
     va_start(args, format);
132
-    debug_log_va(log, format, args);
132
+    debug_log_va(do_log, format, args);
133 133
     va_end(args);
134 134
 }
135 135
 

+ 20
- 20
src/workflow.c Dosyayı Görüntüle

@@ -104,64 +104,64 @@ uint16_t wf_steps(uint16_t index) {
104 104
     return mem_data()->wf[index].count;
105 105
 }
106 106
 
107
-void wf_move_step_down(uint16_t index, uint16_t step) {
107
+void wf_move_step_down(uint16_t index, uint16_t step_i) {
108 108
     if (index >= mem_data()->wf_count) {
109 109
         debug("invalid index %d", index);
110 110
         return;
111 111
     }
112
-    if ((step < 1) || (step >= mem_data()->wf[index].count)) {
113
-        debug("invalid step %d", step);
112
+    if ((step_i < 1) || (step_i >= mem_data()->wf[index].count)) {
113
+        debug("invalid step %d", step_i);
114 114
         return;
115 115
     }
116 116
 
117
-    struct wf_step tmp = mem_data()->wf[index].steps[step - 1];
118
-    mem_data()->wf[index].steps[step - 1] = mem_data()->wf[index].steps[step];
119
-    mem_data()->wf[index].steps[step] = tmp;
117
+    struct wf_step tmp = mem_data()->wf[index].steps[step_i - 1];
118
+    mem_data()->wf[index].steps[step_i - 1] = mem_data()->wf[index].steps[step_i];
119
+    mem_data()->wf[index].steps[step_i] = tmp;
120 120
 }
121 121
 
122
-void wf_move_step_up(uint16_t index, uint16_t step) {
122
+void wf_move_step_up(uint16_t index, uint16_t step_i) {
123 123
     if (index >= mem_data()->wf_count) {
124 124
         debug("invalid index %d", index);
125 125
         return;
126 126
     }
127
-    if (step >= (mem_data()->wf[index].count - 1)) {
128
-        debug("invalid step %d", step);
127
+    if (step_i >= (mem_data()->wf[index].count - 1)) {
128
+        debug("invalid step %d", step_i);
129 129
         return;
130 130
     }
131 131
 
132
-    struct wf_step tmp = mem_data()->wf[index].steps[step + 1];
133
-    mem_data()->wf[index].steps[step + 1] = mem_data()->wf[index].steps[step];
134
-    mem_data()->wf[index].steps[step] = tmp;
132
+    struct wf_step tmp = mem_data()->wf[index].steps[step_i + 1];
133
+    mem_data()->wf[index].steps[step_i + 1] = mem_data()->wf[index].steps[step_i];
134
+    mem_data()->wf[index].steps[step_i] = tmp;
135 135
 }
136 136
 
137
-struct wf_step *wf_get_step(uint16_t index, uint16_t step) {
137
+struct wf_step *wf_get_step(uint16_t index, uint16_t step_i) {
138 138
     if (index >= mem_data()->wf_count) {
139 139
         debug("invalid index %d", index);
140 140
         return NULL;
141 141
     }
142
-    return &mem_data()->wf[index].steps[step];
142
+    return &mem_data()->wf[index].steps[step_i];
143 143
 }
144 144
 
145
-const char *wf_step_str(struct wf_step *step) {
145
+const char *wf_step_str(struct wf_step *step_p) {
146 146
     static char buff[20];
147 147
 
148
-    switch (step->op) {
148
+    switch (step_p->op) {
149 149
     case OP_SET_TEMPERATURE:
150 150
         snprintf(buff, sizeof(buff),
151
-                 "set temp %.1f C", step->val / 10.0f);
151
+                 "set temp %.1f C", step_p->val / 10.0f);
152 152
         break;
153 153
 
154 154
     case OP_WAIT_TEMPERATURE:
155 155
         snprintf(buff, sizeof(buff),
156
-                 "wait temp %.1f C", step->val / 10.0f);
156
+                 "wait temp %.1f C", step_p->val / 10.0f);
157 157
         break;
158 158
 
159 159
     case OP_WAIT_TIME:
160 160
     case OP_PUMP_TIME:
161 161
         snprintf(buff, sizeof(buff),
162 162
                  "%s time %.1f s",
163
-                 (step->op == OP_WAIT_TIME) ? "wait" : "pump",
164
-                 step->val / 1000.0f);
163
+                 (step_p->op == OP_WAIT_TIME) ? "wait" : "pump",
164
+                 step_p->val / 1000.0f);
165 165
         break;
166 166
     }
167 167
 

Loading…
İptal
Kaydet