Skip to content

Add -Werror to acceptance builds for C and CPP #4369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 18, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/ArduinoOTA/examples/OTALeds/OTALeds.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void setup() {
}
});

ArduinoOTA.onError([](ota_error_t error) { ESP.restart(); });
ArduinoOTA.onError([](ota_error_t error) { (void)error; ESP.restart(); });

/* setup the OTA server */
ArduinoOTA.begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ IPAddress netMsk(255, 255, 255, 0);
boolean connect;

/** Last time I tried to connect to WLAN */
long lastConnectTry = 0;
unsigned long lastConnectTry = 0;

/** Current WLAN status */
int status = WL_IDLE_STATUS;
unsigned int status = WL_IDLE_STATUS;

void setup() {
delay(1000);
Expand Down Expand Up @@ -95,7 +95,7 @@ void loop() {
lastConnectTry = millis();
}
{
int s = WiFi.status();
unsigned int s = WiFi.status();
if (s == 0 && millis() > (lastConnectTry + 60000) ) {
/* If WLAN disconnected and idle try to connect */
/* Don't set retry time too low as retry interfere the softAP operation */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Is this an IP? */
boolean isIp(String str) {
for (int i = 0; i < str.length(); i++) {
for (size_t i = 0; i < str.length(); i++) {
int c = str.charAt(i);
if (c != '.' && (c < '0' || c > '9')) {
return false;
Expand Down
23 changes: 11 additions & 12 deletions libraries/ESP8266AVRISP/src/ESP8266AVRISP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ extern "C" {
#define beget16(addr) (*addr * 256 + *(addr+1))

ESP8266AVRISP::ESP8266AVRISP(uint16_t port, uint8_t reset_pin, uint32_t spi_freq, bool reset_state, bool reset_activehigh):
_reset_pin(reset_pin), _reset_state(reset_state), _spi_freq(spi_freq), _reset_activehigh(reset_activehigh),
_server(WiFiServer(port)), _state(AVRISP_STATE_IDLE)
_spi_freq(spi_freq), _server(WiFiServer(port)), _state(AVRISP_STATE_IDLE),
_reset_pin(reset_pin), _reset_state(reset_state), _reset_activehigh(reset_activehigh)
{
pinMode(_reset_pin, OUTPUT);
setReset(_reset_state);
Expand Down Expand Up @@ -71,6 +71,7 @@ AVRISPState_t ESP8266AVRISP::update() {
ip_addr_t lip;
lip.addr = _client.remoteIP();
AVRISP_DEBUG("client connect %d.%d.%d.%d:%d", IP2STR(&lip), _client.remotePort());
(void) lip; // Avoid unused warning when not in debug mode
_client.setTimeout(100); // for getch()
_state = AVRISP_STATE_PENDING;
_reject_incoming();
Expand Down Expand Up @@ -136,10 +137,9 @@ void ESP8266AVRISP::fill(int n) {
}

uint8_t ESP8266AVRISP::spi_transaction(uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
uint8_t n;
SPI.transfer(a);
n = SPI.transfer(b);
n = SPI.transfer(c);
SPI.transfer(b);
SPI.transfer(c);
return SPI.transfer(d);
}

Expand Down Expand Up @@ -233,7 +233,6 @@ void ESP8266AVRISP::end_pmode() {
}

void ESP8266AVRISP::universal() {
int w;
uint8_t ch;

fill(4);
Expand Down Expand Up @@ -265,8 +264,6 @@ int ESP8266AVRISP::addr_page(int addr) {


void ESP8266AVRISP::write_flash(int length) {
uint32_t started = millis();

fill(length);

if (Sync_CRC_EOP == getch()) {
Expand Down Expand Up @@ -331,7 +328,6 @@ void ESP8266AVRISP::program_page() {
int length = 256 * getch();
length += getch();
char memtype = getch();
char buf[100];
// flash memory @here, (length) bytes
if (memtype == 'F') {
write_flash(length);
Expand Down Expand Up @@ -390,7 +386,6 @@ void ESP8266AVRISP::eeprom_read_page(int length) {
}

void ESP8266AVRISP::read_page() {
char result = (char)Resp_STK_FAILED;
int length = 256 * getch();
length += getch();
char memtype = getch();
Expand Down Expand Up @@ -424,9 +419,13 @@ void ESP8266AVRISP::read_signature() {

// It seems ArduinoISP is based on the original STK500 (not v2)
// but implements only a subset of the commands.
int ESP8266AVRISP::avrisp() {
void ESP8266AVRISP::avrisp() {
uint8_t data, low, high;
uint8_t ch = getch();
// Avoid set but not used warning. Leaving them in as it helps document the code
(void) data;
(void) low;
(void) high;
// AVRISP_DEBUG("CMD 0x%02x", ch);
switch (ch) {
case Cmnd_STK_GET_SYNC:
Expand Down Expand Up @@ -517,7 +516,7 @@ int ESP8266AVRISP::avrisp() {

// anything else we will return STK_UNKNOWN
default:
AVRISP_DEBUG("??!?");
AVRISP_DEBUG("?!?");
error++;
if (Sync_CRC_EOP == getch()) {
_client.print((char)Resp_STK_UNKNOWN);
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266AVRISP/src/ESP8266AVRISP.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ESP8266AVRISP {

inline void _reject_incoming(void); // reject any incoming tcp connections

int avrisp(void); // handle incoming STK500 commands
void avrisp(void); // handle incoming STK500 commands

uint8_t getch(void); // retrieve a character from the remote end
uint8_t spi_transaction(uint8_t, uint8_t, uint8_t, uint8_t);
Expand Down
9 changes: 6 additions & 3 deletions libraries/ESP8266LLMNR/ESP8266LLMNR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ bool LLMNRResponder::begin(const char* hostname) {
_hostname.toLowerCase();

_sta_got_ip_handler = WiFi.onStationModeGotIP([this](const WiFiEventStationModeGotIP& event){
(void) event;
_restart();
});

_sta_disconnected_handler = WiFi.onStationModeDisconnected([this](const WiFiEventStationModeDisconnected& event) {
(void) event;
_restart();
});

Expand Down Expand Up @@ -122,6 +124,7 @@ bool LLMNRResponder::_restart() {
_conn->setMulticastTTL(LLMNR_MULTICAST_TTL);
_conn->onRx(std::bind(&LLMNRResponder::_process_packet, this));
_conn->connect(multicast_addr, LLMNR_PORT);
return true;
}

void LLMNRResponder::_process_packet() {
Expand Down Expand Up @@ -242,8 +245,8 @@ void LLMNRResponder::_process_packet() {

// Header
uint8_t header[] = {
id >> 8, id & 0xff, // ID
FLAGS_QR >> 8, 0, // FLAGS
(uint8_t)(id >> 8), (uint8_t)(id & 0xff), // ID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since there's a cast to uint8_t now, masking the low byte with & 0xff is not needed.

(uint8_t)(FLAGS_QR >> 8), 0, // FLAGS
0, 1, // QDCOUNT
0, !!have_rr, // ANCOUNT
0, 0, // NSCOUNT
Expand All @@ -269,7 +272,7 @@ void LLMNRResponder::_process_packet() {
0, 1, // CLASS (IN)
0, 0, 0, 30, // TTL (30 seconds)
0, 4, // RDLENGTH
ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, (ip >> 24) & 0xff, // RDATA
(uint8_t)(ip & 0xff), (uint8_t)((ip >> 8) & 0xff), (uint8_t)((ip >> 16) & 0xff), (uint8_t)((ip >> 24) & 0xff) // RDATA
};
_conn->append(reinterpret_cast<const char*>(rr), sizeof(rr));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool handleFileRead(String path){
if(SPIFFS.exists(pathWithGz))
path += ".gz";
File file = SPIFFS.open(path, "r");
size_t sent = server.streamFile(file, contentType);
server.streamFile(file, contentType);
file.close();
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/examples/NTPClient/NTPClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void loop()
}

// send an NTP request to the time server at the given address
unsigned long sendNTPpacket(IPAddress& address)
void sendNTPpacket(IPAddress& address)
{
Serial.println("sending NTP packet...");
// set all bytes in the buffer to 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ unsigned int readRegister(byte registerName, int numBytes) {
// take the chip select low to select the device:
digitalWrite(chipSelectPin, LOW);
// send the device the register you want to read:
int command = SPI.transfer(registerName);
SPI.transfer(registerName);
// send a value of 0 to read the first byte returned:
inByte = SPI.transfer(0x00);

Expand Down
2 changes: 1 addition & 1 deletion libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void loop()
}

// send an NTP request to the time server at the given address
unsigned long sendNTPpacket(char* address)
void sendNTPpacket(char* address)
{
// set all bytes in the buffer to 0
memset(packetBuffer, 0, NTP_PACKET_SIZE);
Expand Down
13 changes: 9 additions & 4 deletions libraries/Ethernet/src/Dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,12 @@ uint16_t DNSClient::ProcessResponse(uint16_t aTimeout, IPAddress& aAddress)
}
iUdp.read(header, DNS_HEADER_SIZE);

uint16_t header_flags = htons(*((uint16_t*)&header[2]));
uint16_t staging; // Staging used to avoid type-punning warnings
memcpy(&staging, &header[2], sizeof(uint16_t));
uint16_t header_flags = htons(staging);
memcpy(&staging, &header[0], sizeof(uint16_t));
// Check that it's a response to this request
if ( ( iRequestId != (*((uint16_t*)&header[0])) ) ||
if ( ( iRequestId != staging ) ||
((header_flags & QUERY_RESPONSE_MASK) != (uint16_t)RESPONSE_FLAG) )
{
// Mark the entire packet as read
Expand All @@ -301,7 +304,8 @@ uint16_t DNSClient::ProcessResponse(uint16_t aTimeout, IPAddress& aAddress)
}

// And make sure we've got (at least) one answer
uint16_t answerCount = htons(*((uint16_t*)&header[6]));
memcpy(&staging, &header[6], sizeof(uint16_t));
uint16_t answerCount = htons(staging);
if (answerCount == 0 )
{
// Mark the entire packet as read
Expand All @@ -310,7 +314,8 @@ uint16_t DNSClient::ProcessResponse(uint16_t aTimeout, IPAddress& aAddress)
}

// Skip over any questions
for (uint16_t i =0; i < htons(*((uint16_t*)&header[4])); i++)
memcpy(&staging, &header[4], sizeof(uint16_t));
for (uint16_t i =0; i < htons(staging); i++)
{
// Skip over the name
uint8_t len;
Expand Down
1 change: 1 addition & 0 deletions libraries/Ethernet/src/utility/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ uint16_t recvfrom(SOCKET s, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t
*/
void flush(SOCKET s) {
// TODO
(void) s;
}

uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len)
Expand Down
5 changes: 5 additions & 0 deletions libraries/SD/src/SD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ boolean callback_pathExists(SdFile& parentDir, char *filePathComponent,

*/
SdFile child;
(void) isLastComponent;
(void) object;

boolean exists = child.open(parentDir, filePathComponent, O_RDONLY);

Expand Down Expand Up @@ -310,6 +312,8 @@ boolean callback_openPath(SdFile& parentDir, char *filePathComponent,

boolean callback_remove(SdFile& parentDir, char *filePathComponent,
boolean isLastComponent, void *object) {
(void) object;

if (isLastComponent) {
return SdFile::remove(parentDir, filePathComponent);
}
Expand All @@ -318,6 +322,7 @@ boolean callback_remove(SdFile& parentDir, char *filePathComponent,

boolean callback_rmdir(SdFile& parentDir, char *filePathComponent,
boolean isLastComponent, void *object) {
(void) object;
if (isLastComponent) {
SdFile f;
if (!f.open(parentDir, filePathComponent, O_READ)) return false;
Expand Down
3 changes: 2 additions & 1 deletion libraries/SD/src/utility/Sd2Card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ uint8_t Sd2Card::readBlock(uint32_t block, uint8_t* dst) {
*/
uint8_t Sd2Card::readData(uint32_t block,
uint16_t offset, uint16_t count, uint8_t* dst) {
uint16_t n;
if (count == 0) return true;
if ((count + offset) > 512) {
goto fail;
Expand All @@ -414,6 +413,8 @@ uint8_t Sd2Card::readData(uint32_t block,
}

#ifdef OPTIMIZE_HARDWARE_SPI
uint16_t n;

// start first spi transfer
SPDR = 0XFF;

Expand Down
5 changes: 3 additions & 2 deletions libraries/SD/src/utility/SdFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,12 @@ uint8_t SdFile::make83Name(const char* str, uint8_t* name) {
i = 8; // place for extension
} else {
// illegal FAT characters
uint8_t b;
#if defined(__AVR__)
uint8_t b;
PGM_P p = PSTR("|<>^+=?/[];,*\"\\");
while ((b = pgm_read_byte(p++))) if (b == c) return false;
#elif defined(__arm__)
uint8_t b;
const uint8_t valid[] = "|<>^+=?/[];,*\"\\";
const uint8_t *p = valid;
while ((b = *p++)) if (b == c) return false;
Expand Down Expand Up @@ -905,7 +906,7 @@ uint8_t SdFile::rmRfStar(void) {
if (!f.remove()) return false;
}
// position to next entry if required
if (curPosition_ != (32*(index + 1))) {
if (curPosition_ != (uint32_t)(32*(index + 1))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index is uint16_t, and the value is being expanded.
I think this is ok, after reading up on usual arithmetic conversions, but I'm not positive. Please double check that the cast is ok on the final arithmetic result, and that it shouldn't be done directly on index before the arithmetic operations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't mean to expand it, thought curPosition_ was 32-bits. Will correct to uint16_t.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misread your comment, will move the cast inside. No 16 bits.

if (!seekSet(32*(index + 1))) return false;
}
}
Expand Down
3 changes: 2 additions & 1 deletion libraries/SPISlave/examples/SPISlave_Test/SPISlave_Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ void setup()
// It's up to the user to implement protocol for handling data length
SPISlave.onData([](uint8_t * data, size_t len) {
String message = String((char *)data);
(void) len;
if(message.equals("Hello Slave!")) {
SPISlave.setData("Hello Master!");
} else if(message.equals("Are you alive?")) {
char answer[33];
sprintf(answer,"Alive for %u seconds!", millis() / 1000);
sprintf(answer,"Alive for %lu seconds!", millis() / 1000);
SPISlave.setData(answer);
} else {
SPISlave.setData("Say what?");
Expand Down
1 change: 0 additions & 1 deletion libraries/SPISlave/src/hspi_slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ void ICACHE_RAM_ATTR _hspi_slave_isr_handler(void *arg)
if((status & SPISWBIS) != 0 && (_hspi_slave_rx_data_cb)) {
uint8_t i;
uint32_t data;
uint8_t buffer[33];
_hspi_slave_buffer[32] = 0;
for(i=0; i<8; i++) {
data=SPI1W(i);
Expand Down
2 changes: 0 additions & 2 deletions libraries/Servo/src/esp8266/Servo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ uint8_t Servo::attach(int pin, uint16_t minUs, uint16_t maxUs)

void Servo::detach()
{
ServoTimerSequence timerId;

if (s_servos[_servoIndex].info.isActive) {
s_servos[_servoIndex].info.isDetaching = true;
}
Expand Down
Loading