Skip to content

Commit 2126146

Browse files
rodionkvashninigrr
authored andcommitted
Fix warnings (#2881)
* Suppressed -Wunused-parameter and -Wunused-function by casting to void unused identifiers. * Explicit initialization of all fields to suppress -Wmissing-field-initializers. * Fixed signed/unsigned integer comparison. * memset initialization of structs. * More -Wunused-parameter fixes.
1 parent d85e783 commit 2126146

27 files changed

+92
-12
lines changed

cores/esp8266/Esp.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ EspClass ESP;
8383

8484
void EspClass::wdtEnable(uint32_t timeout_ms)
8585
{
86+
(void) timeout_ms;
8687
/// This API can only be called if software watchdog is stopped
8788
system_soft_wdt_restart();
8889
}
@@ -432,7 +433,7 @@ uint32_t EspClass::getSketchSize() {
432433
section_index < image_header.num_segments;
433434
++section_index)
434435
{
435-
section_header_t section_header = {0};
436+
section_header_t section_header = {0, 0};
436437
if (spi_flash_read(pos, (uint32_t*) &section_header, sizeof(section_header))) {
437438
return 0;
438439
}

cores/esp8266/Schedule.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ static int sCount = 0;
1616

1717
static void init_lists()
1818
{
19+
(void) init_lists;
1920
if (sCount != 0) {
2021
return;
2122
}

cores/esp8266/abi.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ void __throw_bad_alloc()
104104

105105
void __throw_logic_error(const char* str)
106106
{
107+
(void) str;
107108
panic();
108109
}
109110

110111
void __throw_out_of_range(const char* str)
111112
{
113+
(void) str;
112114
panic();
113115
}
114116
}

cores/esp8266/cont_util.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void ICACHE_RAM_ATTR cont_init(cont_t* cont) {
3232
cont->struct_start = (unsigned*) cont;
3333

3434
// fill stack with magic values to check high water mark
35-
for(int pos = 0; pos < sizeof(cont->stack) / 4; pos++)
35+
for(int pos = 0; pos < (int)(sizeof(cont->stack) / 4); pos++)
3636
{
3737
cont->stack[pos] = CONT_STACKGUARD;
3838
}

cores/esp8266/core_esp8266_main.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const char* core_release =
5252
} // extern "C"
5353

5454
int atexit(void (*func)()) {
55+
(void) func;
5556
return 0;
5657
}
5758

@@ -125,6 +126,7 @@ static void loop_wrapper() {
125126
}
126127

127128
static void loop_task(os_event_t *events) {
129+
(void) events;
128130
g_micros_at_task_start = system_get_time();
129131
cont_run(&g_cont, &loop_wrapper);
130132
if (cont_check(&g_cont) != 0) {

cores/esp8266/core_esp8266_postmortem.c

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static void print_stack(uint32_t start, uint32_t end);
4646
//static void print_pcs(uint32_t start, uint32_t end);
4747

4848
extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) {
49+
(void) rst_info;
50+
(void) stack;
51+
(void) stack_end;
4952
}
5053

5154
extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback")));
@@ -183,6 +186,7 @@ void abort(){
183186
}
184187

185188
void __assert_func(const char *file, int line, const char *func, const char *what) {
189+
(void) what;
186190
s_panic_file = file;
187191
s_panic_line = line;
188192
s_panic_func = func;

cores/esp8266/core_esp8266_timer.c

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
static volatile timercallback timer1_user_cb = NULL;
3131

3232
void ICACHE_RAM_ATTR timer1_isr_handler(void *para){
33+
(void) para;
3334
if ((T1C & ((1 << TCAR) | (1 << TCIT))) == 0) TEIE &= ~TEIE1;//edge int disable
3435
T1I = 0;
3536
if (timer1_user_cb) {
@@ -77,6 +78,7 @@ void ICACHE_RAM_ATTR timer1_disable(){
7778
static volatile timercallback timer0_user_cb = NULL;
7879

7980
void ICACHE_RAM_ATTR timer0_isr_handler(void* para){
81+
(void) para;
8082
if (timer0_user_cb) {
8183
// to make ISR compatible to Arduino AVR model where interrupts are disabled
8284
// we disable them before we call the client ISR

cores/esp8266/core_esp8266_wiring.c

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static uint32_t micros_overflow_count = 0;
3636
#define REPEAT 1
3737

3838
void delay_end(void* arg) {
39+
(void) arg;
3940
esp_schedule();
4041
}
4142

@@ -53,6 +54,7 @@ void delay(unsigned long ms) {
5354
}
5455

5556
void micros_overflow_tick(void* arg) {
57+
(void) arg;
5658
uint32_t m = system_get_time();
5759
if(m < micros_at_last_overflow_tick)
5860
++micros_overflow_count;

cores/esp8266/core_esp8266_wiring_digital.c

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ static interrupt_handler_t interrupt_handlers[16];
115115
static uint32_t interrupt_reg = 0;
116116

117117
void ICACHE_RAM_ATTR interrupt_handler(void *arg) {
118+
(void) arg;
118119
uint32_t status = GPIE;
119120
GPIEC = status;//clear them interrupts
120121
uint32_t levels = GPI;

cores/esp8266/heap.c

+14
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,60 @@
1010

1111
void* _malloc_r(struct _reent* unused, size_t size)
1212
{
13+
(void) unused;
1314
return malloc(size);
1415
}
1516

1617
void _free_r(struct _reent* unused, void* ptr)
1718
{
19+
(void) unused;
1820
return free(ptr);
1921
}
2022

2123
void* _realloc_r(struct _reent* unused, void* ptr, size_t size)
2224
{
25+
(void) unused;
2326
return realloc(ptr, size);
2427
}
2528

2629
void* _calloc_r(struct _reent* unused, size_t count, size_t size)
2730
{
31+
(void) unused;
2832
return calloc(count, size);
2933
}
3034

3135
void* ICACHE_RAM_ATTR pvPortMalloc(size_t size, const char* file, int line)
3236
{
37+
(void) file;
38+
(void) line;
3339
return malloc(size);
3440
}
3541

3642
void ICACHE_RAM_ATTR vPortFree(void *ptr, const char* file, int line)
3743
{
44+
(void) file;
45+
(void) line;
3846
free(ptr);
3947
}
4048

4149
void* ICACHE_RAM_ATTR pvPortCalloc(size_t count, size_t size, const char* file, int line)
4250
{
51+
(void) file;
52+
(void) line;
4353
return calloc(count, size);
4454
}
4555

4656
void* ICACHE_RAM_ATTR pvPortRealloc(void *ptr, size_t size, const char* file, int line)
4757
{
58+
(void) file;
59+
(void) line;
4860
return realloc(ptr, size);
4961
}
5062

5163
void* ICACHE_RAM_ATTR pvPortZalloc(size_t size, const char* file, int line)
5264
{
65+
(void) file;
66+
(void) line;
5367
return calloc(1, size);
5468
}
5569

cores/esp8266/libc_replacements.c

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ int ICACHE_RAM_ATTR _read_r(struct _reent* unused, int file, char *ptr, int len)
8383
}
8484

8585
int ICACHE_RAM_ATTR _write_r(struct _reent* r, int file, char *ptr, int len) {
86+
(void) r;
8687
if (file == STDOUT_FILENO) {
8788
while(len--) {
8889
ets_putc(*ptr);
@@ -93,6 +94,7 @@ int ICACHE_RAM_ATTR _write_r(struct _reent* r, int file, char *ptr, int len) {
9394
}
9495

9596
int ICACHE_RAM_ATTR _putc_r(struct _reent* r, int c, FILE* file) {
97+
(void) r;
9698
if (file->_file == STDOUT_FILENO) {
9799
return ets_putc(c);
98100
}

cores/esp8266/spiffs/spiffs_hydrogen.c

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh);
2222

2323
#if SPIFFS_BUFFER_HELP
2424
u32_t SPIFFS_buffer_bytes_for_filedescs(spiffs *fs, u32_t num_descs) {
25+
(void) fs;
2526
return num_descs * sizeof(spiffs_fd);
2627
}
2728
#if SPIFFS_CACHE

cores/esp8266/spiffs_api.h

+11-5
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ class SPIFFSImpl : public FSImpl
4949
{
5050
public:
5151
SPIFFSImpl(uint32_t start, uint32_t size, uint32_t pageSize, uint32_t blockSize, uint32_t maxOpenFds)
52-
: _fs({0})
53-
, _start(start)
52+
: _start(start)
5453
, _size(size)
5554
, _pageSize(pageSize)
5655
, _blockSize(blockSize)
5756
, _maxOpenFds(maxOpenFds)
5857
{
58+
memset(&_fs, 0, sizeof(_fs));
5959
}
6060

6161
FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) override;
@@ -176,7 +176,8 @@ class SPIFFSImpl : public FSImpl
176176

177177
bool _tryMount()
178178
{
179-
spiffs_config config = {0};
179+
spiffs_config config;
180+
memset(&config, 0, sizeof(config));
180181

181182
config.hal_read_f = &spiffs_hal_read;
182183
config.hal_write_f = &spiffs_hal_write;
@@ -242,6 +243,11 @@ class SPIFFSImpl : public FSImpl
242243
static void _check_cb(spiffs_check_type type, spiffs_check_report report,
243244
uint32_t arg1, uint32_t arg2)
244245
{
246+
(void) type;
247+
(void) report;
248+
(void) arg1;
249+
(void) arg2;
250+
245251
// TODO: spiffs doesn't pass any context pointer along with _check_cb,
246252
// so we can't do anything useful here other than perhaps
247253
// feeding the watchdog
@@ -268,9 +274,9 @@ class SPIFFSFileImpl : public FileImpl
268274
SPIFFSFileImpl(SPIFFSImpl* fs, spiffs_file fd)
269275
: _fs(fs)
270276
, _fd(fd)
271-
, _stat({0})
272277
, _written(false)
273278
{
279+
memset(&_stat, 0, sizeof(_stat));
274280
_getStat();
275281
}
276282

@@ -376,7 +382,7 @@ class SPIFFSFileImpl : public FileImpl
376382
auto rc = SPIFFS_fstat(_fs->getFs(), _fd, &_stat);
377383
if (rc != SPIFFS_OK) {
378384
DEBUGV("SPIFFS_fstat rc=%d\r\n", rc);
379-
_stat = {0};
385+
memset(&_stat, 0, sizeof(_stat));
380386
}
381387
_written = false;
382388
}

cores/esp8266/time.c

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ void configTime(int timezone, int daylightOffset_sec, const char* server1, const
7777

7878
int clock_gettime(clockid_t unused, struct timespec *tp)
7979
{
80+
(void) unused;
8081
tp->tv_sec = millis() / 1000;
8182
tp->tv_nsec = micros() * 1000;
8283
return 0;
@@ -94,6 +95,8 @@ time_t time(time_t * t)
9495

9596
int _gettimeofday_r(struct _reent* unused, struct timeval *tp, void *tzp)
9697
{
98+
(void) unused;
99+
(void) tzp;
97100
if (tp)
98101
{
99102
ensureBootTimeIsSet();

cores/esp8266/uart.c

+1
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ bool uart_rx_enabled(uart_t* uart)
480480

481481
static void uart_ignore_char(char c)
482482
{
483+
(void) c;
483484
}
484485

485486
static void uart0_write_char(char c)

libraries/ESP8266WebServer/src/Parsing.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ uint8_t ESP8266WebServer::_uploadReadByte(WiFiClient& client){
361361
}
362362

363363
bool ESP8266WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t len){
364-
364+
(void) len;
365365
#ifdef DEBUG_ESP_HTTP_SERVER
366366
DEBUG_OUTPUT.print("Parse Form: Boundary: ");
367367
DEBUG_OUTPUT.print(boundary);

libraries/ESP8266WebServer/src/detail/RequestHandler.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
class RequestHandler {
55
public:
66
virtual ~RequestHandler() { }
7-
virtual bool canHandle(HTTPMethod method, String uri) { return false; }
8-
virtual bool canUpload(String uri) { return false; }
9-
virtual bool handle(ESP8266WebServer& server, HTTPMethod requestMethod, String requestUri) { return false; }
10-
virtual void upload(ESP8266WebServer& server, String requestUri, HTTPUpload& upload) {}
7+
virtual bool canHandle(HTTPMethod method, String uri) { (void) method; (void) uri; return false; }
8+
virtual bool canUpload(String uri) { (void) uri; return false; }
9+
virtual bool handle(ESP8266WebServer& server, HTTPMethod requestMethod, String requestUri) { (void) server; (void) requestMethod; (void) requestUri; return false; }
10+
virtual void upload(ESP8266WebServer& server, String requestUri, HTTPUpload& upload) { (void) server; (void) requestUri; (void) upload; }
1111

1212
RequestHandler* next() { return _next; }
1313
void next(RequestHandler* r) { _next = r; }

libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class FunctionRequestHandler : public RequestHandler {
3131
}
3232

3333
bool handle(ESP8266WebServer& server, HTTPMethod requestMethod, String requestUri) override {
34+
(void) server;
3435
if (!canHandle(requestMethod, requestUri))
3536
return false;
3637

@@ -39,6 +40,8 @@ class FunctionRequestHandler : public RequestHandler {
3940
}
4041

4142
void upload(ESP8266WebServer& server, String requestUri, HTTPUpload& upload) override {
43+
(void) server;
44+
(void) upload;
4245
if (canUpload(requestUri))
4346
_ufn();
4447
}

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ WiFiEventHandler ESP8266WiFiGenericClass::onStationModeGotIP(std::function<void(
153153
WiFiEventHandler ESP8266WiFiGenericClass::onStationModeDHCPTimeout(std::function<void(void)> f)
154154
{
155155
WiFiEventHandler handler = std::make_shared<WiFiEventHandlerOpaque>(WIFI_EVENT_STAMODE_DHCP_TIMEOUT, [f](System_Event_t* e){
156+
(void) e;
156157
f();
157158
});
158159
sCbEventList.push_back(handler);
@@ -452,6 +453,7 @@ int ESP8266WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResul
452453
* @param callback_arg
453454
*/
454455
void wifi_dns_found_callback(const char *name, ip_addr_t *ipaddr, void *callback_arg) {
456+
(void) name;
455457
if(ipaddr) {
456458
(*reinterpret_cast<IPAddress*>(callback_arg)) = ipaddr->addr;
457459
}

libraries/ESP8266WiFi/src/WiFiClient.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ int WiFiClient::connect(IPAddress ip, uint16_t port)
135135

136136
int8_t WiFiClient::_connected(void* pcb, int8_t err)
137137
{
138+
(void) err;
138139
tcp_pcb* tpcb = reinterpret_cast<tcp_pcb*>(pcb);
139140
_client = new ClientContext(tpcb, 0, 0);
140141
_client->ref();
@@ -144,6 +145,7 @@ int8_t WiFiClient::_connected(void* pcb, int8_t err)
144145

145146
void WiFiClient::_err(int8_t err)
146147
{
148+
(void) err;
147149
DEBUGV(":err %d\r\n", err);
148150
esp_schedule();
149151
}
@@ -177,6 +179,7 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
177179

178180
size_t WiFiClient::write(Stream& stream, size_t unused)
179181
{
182+
(void) unused;
180183
return WiFiClient::write(stream);
181184
}
182185

0 commit comments

Comments
 (0)