Skip to content

Commit 9653d64

Browse files
committed
🚨 Fix C++ sign/cast warnings, unused variables
1 parent 6734e82 commit 9653d64

23 files changed

+67
-58
lines changed

actor_model/src/actor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ auto _actor_spawn(
8181
const ExecConfigCallback&& _exec_config_callback
8282
) -> Pid
8383
{
84-
auto&& actor_behaviour = (
84+
auto&& behaviour = (
8585
[actor_behaviours{std::move(_actor_behaviours)}]
8686
(const Pid& pid, Mailbox& mailbox)
8787
-> ResultUnion
@@ -138,13 +138,13 @@ auto _actor_spawn(
138138
{
139139
return node.spawn_link(
140140
*(_initial_link_pid),
141-
actor_behaviour,
141+
behaviour,
142142
std::move(_exec_config_callback)
143143
);
144144
}
145145
else {
146146
return node.spawn(
147-
actor_behaviour,
147+
behaviour,
148148
std::move(_exec_config_callback)
149149
);
150150
}

actor_model/src/mailbox.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ auto Mailbox::receive(bool verify)
190190
if (impl)
191191
{
192192
// Extract an item from the ringbuffer
193-
size_t size = -1;
193+
size_t size = std::numeric_limits<size_t>::max();
194194
auto* flatbuf = xRingbufferReceive(impl, &size, receive_timeout_ticks);
195195

196-
if (flatbuf and size != -1)
196+
if (flatbuf and size != std::numeric_limits<size_t>::max())
197197
{
198198
if (xSemaphoreTake(receive_semaphore, receive_lock_timeout_ticks) == pdTRUE)
199199
{
@@ -230,10 +230,10 @@ auto Mailbox::receive_raw()
230230
if (impl)
231231
{
232232
// Extract an item from the ringbuffer
233-
size_t size = -1;
233+
size_t size = std::numeric_limits<size_t>::max();
234234
auto* flatbuf = xRingbufferReceive(impl, &size, receive_timeout_ticks);
235235

236-
if (flatbuf and size != -1)
236+
if (flatbuf and size != std::numeric_limits<size_t>::max())
237237
{
238238
message = string_view{reinterpret_cast<char*>(flatbuf), size};
239239
}

actor_model/src/oom_killer_actor_behaviour.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,18 @@ auto oom_killer_actor_behaviour(
6666

6767
UBaseType_t tcb_sz;
6868

69-
auto _num_tasks = uxTaskGetSnapshotAll(
69+
uxTaskGetSnapshotAll(
7070
&stack_task_totals[0],
7171
stack_task_totals.size(),
7272
&tcb_sz
7373
);
7474

7575
for (auto& total : stack_task_totals)
7676
{
77-
auto len = (uint32_t)total.pxEndOfStack - (uint32_t)total.pxTopOfStack;
77+
auto len = (
78+
reinterpret_cast<uint32_t>(total.pxEndOfStack)
79+
- reinterpret_cast<uint32_t>(total.pxTopOfStack)
80+
);
7881
tasks_mem_info[total.pxTCB].stack_usage_bytes = len;
7982
}
8083

firmware_update/src/firmware_update.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include <string>
1414
#include <vector>
1515

16-
#include "esp_system.h"
1716
#include "esp_partition.h"
17+
#include "esp_system.h"
1818
#include "mbedtls/md5.h"
1919

2020
namespace FirmwareUpdate {
@@ -101,7 +101,7 @@ auto checksum_partition_md5(
101101
mbedtls_md5_init(&ctx);
102102
mbedtls_md5_starts(&ctx);
103103

104-
for (auto offset = 0; offset < partition_size; offset += buffer_size)
104+
for (auto offset = 0U; offset < partition_size; offset += buffer_size)
105105
{
106106
auto bytes_to_read = (
107107
((offset + buffer_size) <= partition_size)?
@@ -151,10 +151,10 @@ auto checksum_file_md5(
151151
mbedtls_md5_init(&ctx);
152152
mbedtls_md5_starts(&ctx);
153153

154-
for (auto offset = 0; offset < file_size; offset += buffer_size)
154+
for (auto offset = 0L; offset < file_size; offset += buffer_size)
155155
{
156156
auto bytes_to_read = (
157-
((offset + buffer_size) <= file_size)?
157+
(static_cast<ssize_t>(offset + buffer_size) <= file_size)?
158158
buffer_size : (file_size - offset)
159159
);
160160

@@ -189,7 +189,7 @@ auto get_md5sum_hex_str(const MD5Sum& md5sum)
189189
{
190190
std::string md5sum_hex_str(md5sum.size() * 2, 0);
191191

192-
for (auto i = 0; i < md5sum.size(); i++)
192+
for (auto i = 0U; i < md5sum.size(); i++)
193193
{
194194
sprintf(&md5sum_hex_str[i*2], "%02x", md5sum[i]);
195195
}

firmware_update/src/firmware_update_actor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ auto firmware_update_actor_behaviour(
161161
"Invalid FirmwareMetadata buffer received, HTTP response code %d",
162162
response->code()
163163
);
164-
ESP_LOG_BUFFER_HEXDUMP("response_finished", response->body()->data(), response->body()->size(), ESP_LOG_WARN);
164+
ESP_LOG_BUFFER_HEXDUMP(
165+
"response_finished",
166+
response->body()->data(),
167+
static_cast<uint16_t>(response->body()->size()),
168+
ESP_LOG_WARN
169+
);
165170
}
166171

167172
state.firmware_update_check_request_in_progress = false;

googleapis/src/visualization_query_actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ auto visualization_query_actor_behaviour(
493493
send(self, "update_columns", pending_query_intent_mutable_buf);
494494

495495
// Extract the spreadsheet/sheet ids for the query
496-
const auto* query_intent = flatbuffers::GetRoot<QueryIntent>(
496+
query_intent = flatbuffers::GetRoot<QueryIntent>(
497497
pending_query_intent_mutable_buf.data()
498498
);
499499
state.spreadsheet_column_ids_key = make_pair(

http_server/src/http_server_actor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ auto http_server_actor_behaviour(
103103
state.sock_addr.sin_port = htons(http_server_config->port());
104104
auto ret = bind(
105105
state.sockfd,
106-
(struct sockaddr*)&state.sock_addr,
106+
reinterpret_cast<struct sockaddr*>(&state.sock_addr),
107107
sizeof(state.sock_addr)
108108
);
109109

@@ -121,7 +121,6 @@ auto http_server_actor_behaviour(
121121
ret = listen(state.sockfd, 32);
122122
if (ret == 0)
123123
{
124-
socklen_t addr_len = 0;
125124
ESP_LOGI(TAG, "OK");
126125
if (not state.tick_timer_ref)
127126
{
@@ -185,7 +184,7 @@ auto http_server_actor_behaviour(
185184
socklen_t addr_len = 0;
186185
state.client_sockfd = accept(
187186
state.sockfd,
188-
(struct sockaddr *)&state.sock_addr,
187+
reinterpret_cast<struct sockaddr *>(&state.sock_addr),
189188
&addr_len
190189
);
191190

jwt/src/jwt.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ auto esp32_gen_random_bytes(void *ctx, unsigned char *buf, size_t len)
2626
auto esp32_gen_random_bytes(void *ctx, unsigned char *buf, size_t len)
2727
-> int
2828
{
29-
auto i = 0;
29+
auto i = 0U;
3030
// Fill up the buffer 32-bits at a time (4 chars each gen)
31-
for (auto off=0; off<len; off+=4)
31+
for (auto off=0U; off<len; off+=4)
3232
{
3333
// Get 32-bits of random from esp32 H/W RNG
3434
uint32_t r = esp_random();
3535

36-
if (i<=len) { buf[i++] = (r >> 0) & 0xff; }
37-
if (i<=len) { buf[i++] = (r >> 8) & 0xff; }
38-
if (i<=len) { buf[i++] = (r >> 16) & 0xff; }
39-
if (i<=len) { buf[i++] = (r >> 24) & 0xff; }
36+
if (i<=len) { buf[i++] = static_cast<uint8_t>(r >> 0); }
37+
if (i<=len) { buf[i++] = static_cast<uint8_t>(r >> 8); }
38+
if (i<=len) { buf[i++] = static_cast<uint8_t>(r >> 16); }
39+
if (i<=len) { buf[i++] = static_cast<uint8_t>(r >> 24); }
4040
}
4141

4242
return 0;

module_manager/src/file_buffer_loader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ auto FileBufferLoader::load(const off_t offset, const size_t size)
6464

6565
if (file != nullptr)
6666
{
67-
auto in_range = ((offset + size) <= file_len);
67+
auto in_range = ((offset + static_cast<ssize_t>(size)) <= file_len);
6868
if (in_range)
6969
{
7070
const auto key = std::make_pair(offset, size);
@@ -88,7 +88,7 @@ auto FileBufferLoader::load(const off_t offset, const size_t size)
8888
file
8989
);
9090

91-
if (bytes_read == size)
91+
if (bytes_read == static_cast<ssize_t>(size))
9292
{
9393
loaded_block = new_block.first;
9494
}

module_manager/src/file_buffer_loader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
#include "elf/elf++.hh"
1414

15-
#include <string_view>
1615
#include <string>
16+
#include <string_view>
1717
#include <unordered_map>
1818

1919
namespace ModuleManager {
@@ -27,7 +27,7 @@ class FileBufferLoader
2727
virtual ~FileBufferLoader();
2828

2929
auto load(const off_t offset, const size_t size)
30-
-> const void*;
30+
-> const void* override;
3131
auto extract(const off_t offset, const size_t size)
3232
-> void*;
3333

0 commit comments

Comments
 (0)