Fix more warnings seen with "--warnings more"

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
Álvaro Fernández Rojas 2023-05-31 18:37:13 +02:00
parent 5b0e19438a
commit a1d4a36379
11 changed files with 59 additions and 45 deletions

View file

@ -291,6 +291,8 @@ void somfy_frame_t::encodeFrame(byte *frame) {
case somfy_commands::Flag:
frame[0] = 142;
break;
default:
break;
}
}
else {
@ -310,6 +312,8 @@ void somfy_frame_t::encodeFrame(byte *frame) {
frame[8] = 0;
frame[9] = 25;
break;
default:
break;
}
}
byte checksum = 0;
@ -1039,6 +1043,8 @@ void SomfyShade::processWaitingFrame() {
Serial.println(" repeats");
}
break;
default:
break;
}
}
}
@ -1060,7 +1066,6 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
if(!hasRemote) return;
this->lastFrame.copy(frame);
int8_t dir = 0;
int8_t tiltDir = 0;
this->moveStart = this->tiltStart = millis();
this->startPos = this->currentPos;
this->startTiltPos = this->currentTiltPos;
@ -1336,7 +1341,6 @@ void SomfyShade::sendTiltCommand(somfy_commands cmd) {
}
}
void SomfyShade::moveToTiltTarget(float target) {
int8_t newDir = 0;
somfy_commands cmd = somfy_commands::My;
if(target < this->currentTiltPos)
cmd = somfy_commands::Up;
@ -1361,7 +1365,6 @@ void SomfyShade::moveToTiltTarget(float target) {
this->settingTiltPos = true;
}
void SomfyShade::moveToTarget(float pos, float tilt) {
int8_t newDir = 0;
somfy_commands cmd = somfy_commands::My;
if(pos < this->currentPos)
cmd = somfy_commands::Up;
@ -1552,7 +1555,6 @@ void SomfyShadeController::publish() {
mqtt.publish("shades", arr);
}
uint8_t SomfyShadeController::getNextShadeId() {
uint8_t nextId = 0;
// There is no shortcut for this since the deletion of
// a shade in the middle makes all of this very difficult.
for(uint8_t i = 1; i < SOMFY_MAX_SHADES - 1; i++) {
@ -1792,7 +1794,7 @@ bool SomfyShadeController::toJSON(JsonArray &arr) {
}
void SomfyShadeController::loop() {
this->transceiver.loop();
for(uint8_t i; i < SOMFY_MAX_SHADES; i++) {
for(uint8_t i = 0; i < SOMFY_MAX_SHADES; i++) {
if(this->shades[i].getShadeId() != 255) this->shades[i].checkMovement();
}
// Only commit the file once per second.
@ -1824,7 +1826,6 @@ static const uint32_t tempo_if_gap = 30415; // Gap between frames
static int16_t bitMin = SYMBOL * TOLERANCE_MIN;
static uint16_t timing_index = 0;
static somfy_rx_t somfy_rx;
static somfy_rx_queue_t rx_queue;
@ -1834,7 +1835,7 @@ bool somfy_tx_queue_t::pop(somfy_tx_t *tx) {
if(this->index[i] < MAX_TX_BUFFER) {
uint8_t ndx = this->index[i];
memcpy(tx, &this->items[ndx], sizeof(somfy_tx_t));
memset(&this->items[ndx], 0x00, sizeof(somfy_tx_t));
this->items[ndx].clear();
this->length--;
this->index[i] = 255;
return true;
@ -1847,7 +1848,8 @@ bool somfy_tx_queue_t::push(uint32_t await, somfy_commands cmd, uint8_t repeats)
uint8_t ndx = this->index[MAX_TX_BUFFER - 1];
this->index[MAX_TX_BUFFER - 1] = 255;
this->length = MAX_TX_BUFFER - 1;
if(ndx < MAX_TX_BUFFER) memset(&this->items[ndx], 0x00, sizeof(somfy_tx_t));
if(ndx < MAX_TX_BUFFER)
this->items[ndx].clear();
}
// Place the command in the first empty slot. Empty slots are those
// with a millis of 0. We will shift the indexes right so that this
@ -1870,7 +1872,8 @@ bool somfy_tx_queue_t::push(uint32_t await, somfy_commands cmd, uint8_t repeats)
}
void somfy_rx_queue_t::init() {
Serial.println("Initializing RX Queue");
memset(&this->items[0], 0x00, sizeof(somfy_rx_t) * MAX_RX_BUFFER);
for (uint8_t i = 0; i < MAX_RX_BUFFER; i++)
this->items[i].clear();
memset(&this->index[0], 0xFF, MAX_RX_BUFFER);
this->length = 0;
}
@ -1882,7 +1885,7 @@ bool somfy_rx_queue_t::pop(somfy_rx_t *rx) {
if(this->index[i] < MAX_RX_BUFFER) {
uint8_t ndx = this->index[i];
memcpy(rx, &this->items[this->index[i]], sizeof(somfy_rx_t));
memset(&this->items[ndx], 0x00, sizeof(somfy_rx_t));
this->items[ndx].clear();
this->length--;
this->index[i] = 255;
return true;
@ -2124,7 +2127,7 @@ void Transceiver::emitFrame(somfy_frame_t *frame, somfy_rx_t *rx) {
evt.appendMessage(buf);
snprintf(buf, sizeof(buf), "\"rcode\":%d,", frame->rollingCode);
evt.appendMessage(buf);
snprintf(buf, sizeof(buf), "\"command\":\"%s\",", translateSomfyCommand(frame->cmd));
snprintf(buf, sizeof(buf), "\"command\":\"%s\",", translateSomfyCommand(frame->cmd).c_str());
evt.appendMessage(buf);
snprintf(buf, sizeof(buf), "\"rssi\":%d,", frame->rssi);
evt.appendMessage(buf);