Skip to content

Commit bfa23be

Browse files
committed
warning cleanup: mark unused parameters with ARG_UNUSED macro
Use the ARG_UNUSED macro provided by Zephyr to mark function parameters as intentionally unused to prevent compiler warnings. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
1 parent ae6d64b commit bfa23be

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

libraries/SocketWrapper/SocketHelpers.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ void NetworkInterface::event_handler(struct net_mgmt_event_callback *cb, uint64_
1010
struct net_if *iface) {
1111
int i = 0;
1212

13+
ARG_UNUSED(cb);
14+
1315
if (mgmt_event != NET_EVENT_IPV4_ADDR_ADD) {
1416
return;
1517
}
@@ -38,6 +40,10 @@ void NetworkInterface::option_handler(struct net_dhcpv4_option_callback *cb, siz
3840
enum net_dhcpv4_msg_type msg_type, struct net_if *iface) {
3941
char buf[NET_IPV4_ADDR_LEN];
4042

43+
ARG_UNUSED(length);
44+
ARG_UNUSED(msg_type);
45+
ARG_UNUSED(iface);
46+
4147
LOG_INF("DHCP Option %d: %s", cb->option, net_addr_ntop(AF_INET, cb->data, buf, sizeof(buf)));
4248
}
4349

@@ -185,9 +191,9 @@ void NetworkInterface::setGatewayIP(const IPAddress gateway) {
185191
gw_addr.s_addr = gateway;
186192
net_if_ipv4_set_gw(netif, &gw_addr);
187193
LOG_INF("Gateway IP set: %s", gateway.toString().c_str());
188-
return;
189194
}
190195

191196
void NetworkInterface::setDnsServerIP(const IPAddress dns_server) {
192-
return; // DNS server dynamic configuration is not supported
197+
// DNS server dynamic configuration is not supported
198+
ARG_UNUSED(dns_server);
193199
}

libraries/SocketWrapper/ZephyrServer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class ZephyrServer : public arduino::Server, ZephyrSocketWrapper {
4040
}
4141

4242
ZephyrClient accept(uint8_t *status = nullptr) {
43+
ARG_UNUSED(status);
44+
4345
ZephyrClient client;
4446
int sock = ZephyrSocketWrapper::accept();
4547
client.setSocket(sock);

libraries/WiFi/src/WiFi.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ String WiFiClass::firmwareVersion() {
1212

1313
int WiFiClass::begin(const char *ssid, const char *passphrase, wl_enc_type security,
1414
bool blocking) {
15+
ARG_UNUSED(security); // currently unsupported
16+
1517
sta_iface = net_if_get_wifi_sta();
1618
netif = sta_iface;
1719
sta_config.ssid = (const uint8_t *)ssid;

libraries/Wire/Wire.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ uint8_t arduino::ZephyrI2C::endTransmission(bool stopBit) {
100100
size_t max = ring_buf_capacity_get(&txRingBuffer.rb);
101101
size_t len = ring_buf_get_claim(&txRingBuffer.rb, &buf, max);
102102

103+
ARG_UNUSED(stopBit);
104+
103105
ret = i2c_write(i2c_dev, buf, len, _address);
104106

105107
// Must be called even if 0 bytes claimed.
@@ -115,8 +117,11 @@ uint8_t arduino::ZephyrI2C::endTransmission(void) {
115117
size_t arduino::ZephyrI2C::requestFrom(uint8_t address, size_t len_in, bool stopBit) {
116118
int ret = -EIO;
117119
uint8_t *buf = NULL;
118-
size_t len = ring_buf_put_claim(&rxRingBuffer.rb, &buf, len_in);
120+
size_t len;
121+
122+
ARG_UNUSED(stopBit);
119123

124+
len = ring_buf_put_claim(&rxRingBuffer.rb, &buf, len_in);
120125
if (len && buf) {
121126
ret = i2c_read(i2c_dev, buf, len, address);
122127
}
@@ -171,6 +176,8 @@ void arduino::ZephyrI2C::onRequest(voidFuncPtr cb) {
171176
}
172177

173178
int arduino::ZephyrI2C::writeRequestedCallback(struct i2c_target_config *config) {
179+
ARG_UNUSED(config);
180+
174181
// Reset the buffer on write requests.
175182
ring_buf_reset(&rxRingBuffer.rb);
176183
return 0;
@@ -180,6 +187,8 @@ int arduino::ZephyrI2C::writeReceivedCallback(struct i2c_target_config *config,
180187
size_t len = ring_buf_size_get(&rxRingBuffer.rb);
181188
size_t max = ring_buf_capacity_get(&rxRingBuffer.rb);
182189

190+
ARG_UNUSED(config);
191+
183192
// If the buffer is about to overflow, invoke the callback
184193
// with the current length.
185194
if (onReceiveCb && ((len + 1) > max)) {
@@ -201,6 +210,8 @@ int arduino::ZephyrI2C::readRequestedCallback(struct i2c_target_config *config,
201210
}
202211

203212
int arduino::ZephyrI2C::readProcessedCallback(struct i2c_target_config *config, uint8_t *val) {
213+
ARG_UNUSED(config);
214+
204215
*val = 0xFF;
205216
ring_buf_get(&txRingBuffer.rb, val, 1);
206217
// Returning a negative value here is not handled gracefully and
@@ -209,6 +220,8 @@ int arduino::ZephyrI2C::readProcessedCallback(struct i2c_target_config *config,
209220
}
210221

211222
int arduino::ZephyrI2C::stopCallback(struct i2c_target_config *config) {
223+
ARG_UNUSED(config);
224+
212225
// If the RX buffer is not empty invoke the callback with the
213226
// remaining data length.
214227
if (onReceiveCb) {

libraries/Zephyr_SDRAM/examples/SDRAM_operations/SDRAM_operations.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ void frameBuffer() {
3636
// simply initialize the memory as
3737

3838
SDRAM.begin(SDRAM_START_ADDRESS + 2 * 1024 * 1024);
39-
// 2MB of contiguous memory available at the beginning
4039

40+
// 2MB of contiguous memory available at the beginning
4141
uint32_t* framebuffer = (uint32_t*)SDRAM_START_ADDRESS;
4242

43-
// We can't allocate anymore the huge 7MB array
44-
43+
// We can't allocate the huge 7MB array anymore
4544
uint8_t* myVeryBigArray = (uint8_t*)SDRAM.malloc(7 * 1024 * 1024);
4645
if (myVeryBigArray == NULL) {
4746
Serial.println("Oops, too big :)");
4847
}
4948

49+
ARG_UNUSED(framebuffer); // suppress unused variable warning
5050
}
5151

5252
void setup() {
@@ -65,4 +65,4 @@ void setup() {
6565

6666
void loop() {
6767

68-
}
68+
}

0 commit comments

Comments
 (0)