Skip to content

Commit 8ad92cb

Browse files
authored
Merge pull request #556 from pennam/warns
Reduce build warnings
2 parents 98938b1 + fd2e4ee commit 8ad92cb

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

src/ArduinoIoTCloudDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleSendCapabilities() {
123123
deliver(reinterpret_cast<Message*>(&versionMessage));
124124
#endif
125125
/* Subscribe to device topic to request */
126-
ThingBeginCmd thingBegin = { ThingBeginCmdId };
126+
ThingBeginCmd thingBegin = { ThingBeginCmdId, {} };
127127
deliver(reinterpret_cast<Message*>(&thingBegin));
128128

129129
/* No device configuration received. Wait: 4s -> 8s -> 16s -> 32s -> 32s ...*/

src/ota/implementation/OTAUnoR4.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ UNOR4OTACloudProcess::UNOR4OTACloudProcess(MessageStream *ms)
3232
}
3333

3434
OTACloudProcessInterface::State UNOR4OTACloudProcess::resume(Message* msg) {
35+
(void)msg;
3536
return OtaBegin;
3637
}
3738

@@ -57,22 +58,25 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::startOTA() {
5758
}
5859

5960
OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() {
60-
int ota_err = OTAUpdate::OTA_ERROR_NONE;
61-
6261
String fv = WiFi.firmwareVersion();
63-
if(fv >= "0.5.0") {
62+
/* Firmware supports non blocking OTA */
63+
if (fv >= "0.5.0") {
6464
auto progress = ota.downloadProgress();
65+
if (progress < 0) {
66+
return OtaDownloadFail;
67+
}
6568

66-
if((millis() - context->lastReportTime) > 5000) { // Report the download progress each X millisecond
69+
if ((millis() - context->lastReportTime) > 5000) { // Report the download progress each X millisecond
6770
DEBUG_VERBOSE("OTA Download Progress %d/%d", progress, context->downloadSize);
6871

6972
reportStatus(progress);
7073
context->lastReportTime = millis();
7174
}
7275

73-
if(progress < context->downloadSize) {
76+
/* It is safe to cast progress here because we are sure that is positive */
77+
if ((size_t)progress < context->downloadSize) {
7478
return Fetch;
75-
} else if(progress > context->downloadSize || progress < 0) {
79+
} else if ((size_t)progress > context->downloadSize) {
7680
return OtaDownloadFail;
7781
} else {
7882
return FlashOTA;
@@ -85,7 +89,6 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() {
8589
}
8690

8791
DEBUG_VERBOSE("OTAUpdate::download() %d bytes downloaded", ota_download);
88-
8992
return FlashOTA;
9093
}
9194
}
@@ -99,13 +102,18 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::flashOTA() {
99102
}
100103

101104
/* Flash new firmware */
102-
if ((ota_err = ota.update(UPDATE_FILE_NAME)) != OTAUpdate::OTA_ERROR_NONE) { // This reboots the MCU
105+
if ((ota_err = ota.update(UPDATE_FILE_NAME)) != OTAUpdate::OTA_ERROR_NONE) {
103106
DEBUG_VERBOSE("OTAUpdate::update() failed with %d", ota_err);
104107
return convertUnor4ErrorToState(ota_err);
105108
}
109+
110+
/* This is never called because ota.uptade reboots the microcontroller */
111+
return Resume;
106112
}
107113

108114
OTACloudProcessInterface::State UNOR4OTACloudProcess::reboot() {
115+
/* This is never called; the microcontroller reboots in flashOTA state */
116+
return Resume;
109117
}
110118

111119
void UNOR4OTACloudProcess::reset() {

src/ota/interface/OTAInterface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ OTACloudProcessInterface::State OTACloudProcessInterface::otaBegin() {
106106

107107
struct OtaBeginUp msg = {
108108
OtaBeginUpId,
109+
{}
109110
};
110111

111112
SHA256 sha256_calc;
@@ -199,6 +200,7 @@ void OTACloudProcessInterface::reportStatus(int32_t state_data) {
199200

200201
struct OtaProgressCmdUp msg = {
201202
OtaProgressCmdUpId,
203+
{}
202204
};
203205

204206
memcpy(msg.params.id, context->id, ID_SIZE);

src/ota/interface/OTAInterfaceDefault.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#include "OTAInterfaceDefault.h"
1515
#include "../OTA.h"
1616

17-
static uint32_t crc_update(uint32_t crc, const void * data, size_t data_len);
18-
1917
OTADefaultCloudProcessInterface::OTADefaultCloudProcessInterface(MessageStream *ms, Client* client)
2018
: OTACloudProcessInterface(ms)
2119
, client(client)

src/property/types/automation/CloudTelevision.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,14 @@ class CloudTelevision : public Property {
226226
setAttribute(_cloud_value.swi, "swi");
227227
setAttribute(_cloud_value.vol, "vol");
228228
setAttribute(_cloud_value.mut, "mut");
229+
/* PlaybackCommands and InputValue are enum of type int so we can safely disable
230+
* strict aliasing warnings here.
231+
*/
232+
#pragma GCC diagnostic push
233+
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
229234
setAttribute((int&)_cloud_value.pbc, "pbc");
230235
setAttribute((int&)_cloud_value.inp, "inp");
236+
#pragma GCC diagnostic pop
231237
setAttribute(_cloud_value.cha, "cha");
232238
}
233239
};

0 commit comments

Comments
 (0)