Skip to content

Commit fd2e4ee

Browse files
committed
UNOR4 OTA: fix signed comparison warning
1 parent aad8c4b commit fd2e4ee

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/ota/implementation/OTAUnoR4.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,24 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::startOTA() {
5959

6060
OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() {
6161
String fv = WiFi.firmwareVersion();
62-
if(fv >= "0.5.0") {
62+
/* Firmware supports non blocking OTA */
63+
if (fv >= "0.5.0") {
6364
auto progress = ota.downloadProgress();
65+
if (progress < 0) {
66+
return OtaDownloadFail;
67+
}
6468

65-
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
6670
DEBUG_VERBOSE("OTA Download Progress %d/%d", progress, context->downloadSize);
6771

6872
reportStatus(progress);
6973
context->lastReportTime = millis();
7074
}
7175

72-
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) {
7378
return Fetch;
74-
} else if(progress > context->downloadSize || progress < 0) {
79+
} else if ((size_t)progress > context->downloadSize) {
7580
return OtaDownloadFail;
7681
} else {
7782
return FlashOTA;
@@ -84,7 +89,6 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() {
8489
}
8590

8691
DEBUG_VERBOSE("OTAUpdate::download() %d bytes downloaded", ota_download);
87-
8892
return FlashOTA;
8993
}
9094
}

0 commit comments

Comments
 (0)