mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-27 10:51:34 +02:00
When building the core with `-Wextra` a few locations have `case:` fall throughs or skipped field initializers. Add proper comments for B64 cases to avoid GCC warnings Initialized unused fields in Tone and WiFiGeneric to avoid missing field initializer warnings. ```` 2022-05-19T17:40:42.2280300Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cdecode.c: In function 'base64_decode_block_signed': 2022-05-19T17:40:42.2282122Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cdecode.c:42:23: warning: this statement may fall through [-Wimplicit-fallthrough=] 2022-05-19T17:40:42.2283247Z *plainchar = (fragment & 0x03f) << 2; 2022-05-19T17:40:42.2284240Z ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 2022-05-19T17:40:42.2285087Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cdecode.c:43:7: note: here 2022-05-19T17:40:42.2285435Z case step_b: 2022-05-19T17:40:42.2285691Z ^~~~ 2022-05-19T17:40:42.2286515Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cdecode.c:53:23: warning: this statement may fall through [-Wimplicit-fallthrough=] 2022-05-19T17:40:42.2286932Z *plainchar = (fragment & 0x00f) << 4; 2022-05-19T17:40:42.2287219Z ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 2022-05-19T17:40:42.2287609Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cdecode.c:54:7: note: here 2022-05-19T17:40:42.2287909Z case step_c: 2022-05-19T17:40:42.2288200Z ^~~~ 2022-05-19T17:40:42.2288972Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cdecode.c:64:23: warning: this statement may fall through [-Wimplicit-fallthrough=] 2022-05-19T17:40:42.2289491Z *plainchar = (fragment & 0x003) << 6; 2022-05-19T17:40:42.2289745Z ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 2022-05-19T17:40:42.2290162Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cdecode.c:65:7: note: here 2022-05-19T17:40:42.2290509Z case step_d: 2022-05-19T17:40:42.2290714Z ^~~~ 2022-05-19T17:40:42.2482744Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cencode.c: In function 'base64_encode_block': 2022-05-19T17:40:42.2484713Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cencode.c:46:20: warning: this statement may fall through [-Wimplicit-fallthrough=] 2022-05-19T17:40:42.2485415Z result = (fragment & 0x003) << 4; 2022-05-19T17:40:42.2486713Z ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 2022-05-19T17:40:42.2487696Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cencode.c:47:9: note: here 2022-05-19T17:40:42.2488519Z case step_B: 2022-05-19T17:40:42.2489175Z ^~~~ 2022-05-19T17:40:42.2492458Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cencode.c:56:20: warning: this statement may fall through [-Wimplicit-fallthrough=] 2022-05-19T17:40:42.2493351Z result = (fragment & 0x00f) << 2; 2022-05-19T17:40:42.2494227Z ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 2022-05-19T17:40:42.2496324Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/libb64/cencode.c:57:9: note: here 2022-05-19T17:40:42.2496937Z case step_C: 2022-05-19T17:40:42.2497261Z ^~~~ 2022-05-19T17:40:44.6354962Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/Tone.cpp: In function 'void setToneChannel(uint8_t)': 2022-05-19T17:40:44.6356417Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/Tone.cpp:99:5: warning: missing initializer for member 'tone_msg_t::pin' [-Wmissing-field-initializers] 2022-05-19T17:40:44.6357120Z }; 2022-05-19T17:40:44.6358732Z ^ 2022-05-19T17:40:44.6364470Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/Tone.cpp:99:5: warning: missing initializer for member 'tone_msg_t::frequency' [-Wmissing-field-initializers] 2022-05-19T17:40:44.6367914Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/Tone.cpp:99:5: warning: missing initializer for member 'tone_msg_t::duration' [-Wmissing-field-initializers] 2022-05-19T17:40:44.6372875Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/Tone.cpp: In function 'void noTone(uint8_t)': 2022-05-19T17:40:44.6373943Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/Tone.cpp:110:5: warning: missing initializer for member 'tone_msg_t::frequency' [-Wmissing-field-initializers] 2022-05-19T17:40:44.6375154Z }; 2022-05-19T17:40:44.6375825Z ^ 2022-05-19T17:40:44.6379852Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/Tone.cpp:110:5: warning: missing initializer for member 'tone_msg_t::duration' [-Wmissing-field-initializers] 2022-05-19T17:40:44.6383291Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/Tone.cpp:110:5: warning: missing initializer for member 'tone_msg_t::channel' [-Wmissing-field-initializers] 2022-05-19T17:40:44.6388688Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/Tone.cpp: In function 'void tone(uint8_t, unsigned int, long unsigned int)': 2022-05-19T17:40:44.6389829Z /home/runner/arduino_ide/hardware/espressif/esp32/cores/esp32/Tone.cpp:128:5: warning: missing initializer for member 'tone_msg_t::channel' [-Wmissing-field-initializers] 2022-05-19T17:40:44.6390677Z }; 2022-05-19T17:40:44.6391420Z ^ 2022-05-19T17:42:00.6768353Z /home/runner/arduino_ide/hardware/espressif/esp32/libraries/WiFi/src/WiFiGeneric.cpp: In static member function 'static bool WiFiGenericClass::setDualAntennaConfig(uint8_t, uint8_t, wifi_rx_ant_t, wifi_tx_ant_t)': 2022-05-19T17:42:00.6769293Z /home/runner/arduino_ide/hardware/espressif/esp32/libraries/WiFi/src/WiFiGeneric.cpp:1333:5: warning: missing initializer for member 'wifi_ant_config_t::rx_ant_default' [-Wmissing-field-initializers] 2022-05-19T17:42:00.6769658Z }; 2022-05-19T17:42:00.6769824Z ^ ````
103 lines
3.6 KiB
C
103 lines
3.6 KiB
C
/*
|
|
cdecoder.c - c source to a base64 decoding algorithm implementation
|
|
|
|
This is part of the libb64 project, and has been placed in the public domain.
|
|
For details, see http://sourceforge.net/projects/libb64
|
|
*/
|
|
|
|
#include "cdecode.h"
|
|
#include <stdint.h>
|
|
|
|
static int base64_decode_value_signed(int8_t value_in){
|
|
static const int8_t decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,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,-1,-1,-1,-1,-1,-1,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};
|
|
static const int8_t decoding_size = sizeof(decoding);
|
|
value_in -= 43;
|
|
if (value_in < 0 || value_in >= decoding_size) return -1;
|
|
return decoding[(int)value_in];
|
|
}
|
|
|
|
void base64_init_decodestate(base64_decodestate* state_in){
|
|
state_in->step = step_a;
|
|
state_in->plainchar = 0;
|
|
}
|
|
|
|
static int base64_decode_block_signed(const int8_t* code_in, const int length_in, int8_t* plaintext_out, base64_decodestate* state_in){
|
|
const int8_t* codechar = code_in;
|
|
int8_t* plainchar = plaintext_out;
|
|
int8_t fragment;
|
|
|
|
*plainchar = state_in->plainchar;
|
|
|
|
switch (state_in->step){
|
|
while (1){
|
|
case step_a:
|
|
do {
|
|
if (codechar == code_in+length_in){
|
|
state_in->step = step_a;
|
|
state_in->plainchar = *plainchar;
|
|
return plainchar - plaintext_out;
|
|
}
|
|
fragment = (int8_t)base64_decode_value_signed(*codechar++);
|
|
} while (fragment < 0);
|
|
*plainchar = (fragment & 0x03f) << 2;
|
|
// fall through
|
|
case step_b:
|
|
do {
|
|
if (codechar == code_in+length_in){
|
|
state_in->step = step_b;
|
|
state_in->plainchar = *plainchar;
|
|
return plainchar - plaintext_out;
|
|
}
|
|
fragment = (int8_t)base64_decode_value_signed(*codechar++);
|
|
} while (fragment < 0);
|
|
*plainchar++ |= (fragment & 0x030) >> 4;
|
|
*plainchar = (fragment & 0x00f) << 4;
|
|
// fall through
|
|
case step_c:
|
|
do {
|
|
if (codechar == code_in+length_in){
|
|
state_in->step = step_c;
|
|
state_in->plainchar = *plainchar;
|
|
return plainchar - plaintext_out;
|
|
}
|
|
fragment = (int8_t)base64_decode_value_signed(*codechar++);
|
|
} while (fragment < 0);
|
|
*plainchar++ |= (fragment & 0x03c) >> 2;
|
|
*plainchar = (fragment & 0x003) << 6;
|
|
// fall through
|
|
case step_d:
|
|
do {
|
|
if (codechar == code_in+length_in){
|
|
state_in->step = step_d;
|
|
state_in->plainchar = *plainchar;
|
|
return plainchar - plaintext_out;
|
|
}
|
|
fragment = (int8_t)base64_decode_value_signed(*codechar++);
|
|
} while (fragment < 0);
|
|
*plainchar++ |= (fragment & 0x03f);
|
|
}
|
|
}
|
|
/* control should not reach here */
|
|
return plainchar - plaintext_out;
|
|
}
|
|
|
|
static int base64_decode_chars_signed(const int8_t* code_in, const int length_in, int8_t* plaintext_out){
|
|
base64_decodestate _state;
|
|
base64_init_decodestate(&_state);
|
|
int len = base64_decode_block_signed(code_in, length_in, plaintext_out, &_state);
|
|
if(len > 0) plaintext_out[len] = 0;
|
|
return len;
|
|
}
|
|
|
|
int base64_decode_value(char value_in){
|
|
return base64_decode_value_signed(*((int8_t *) &value_in));
|
|
}
|
|
|
|
int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in){
|
|
return base64_decode_block_signed((int8_t *) code_in, length_in, (int8_t *) plaintext_out, state_in);
|
|
}
|
|
|
|
int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out){
|
|
return base64_decode_chars_signed((int8_t *) code_in, length_in, (int8_t *) plaintext_out);
|
|
}
|