Skip to content

Commit c986f53

Browse files
committed
warning cleanup: misc fixes
- Arduino_LED_Matrix: fix packed attribute placement, add missing dependency - Camera: fix pixel format check (formats are uint32_t, not pointers) - Ethernet: fix float division literals - SocketWrapper: hide deprecated warnings, fix signed/unsigned compare - Wire: hide pedantic 'invalid offsetof' warning
1 parent 7ad58a2 commit c986f53

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

libraries/Arduino_LED_Matrix/examples/Reflash_Bootanimation/bootanimation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "stdint.h"
22

3-
__attribute__((packed)) struct bootanimation_user_data {
3+
struct bootanimation_user_data {
44
size_t magic; // must be 0xBA for bootanimation
55
size_t len_loop;
66
size_t len_end;
77
size_t empty;
88
uint8_t *buf_loop;
9-
};
9+
} __attribute__((packed));
1010

1111
unsigned int bootanimation_end_len = 3120;
1212
unsigned int bootanimation_len = 18720;

libraries/Arduino_LED_Matrix/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ paragraph=This library provides a simple interface for controlling the LED matri
77
category=Communication
88
url=https://www.arduino.cc/
99
architectures=*
10-
depends=
10+
depends=ArduinoGraphics

libraries/Camera/src/camera.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ bool Camera::begin(uint32_t width, uint32_t height, uint32_t pixformat, bool byt
7878
return false;
7979
}
8080

81-
for (size_t i = 0; caps.format_caps[i].pixelformat != NULL; i++) {
81+
for (size_t i = 0; caps.format_caps[i].pixelformat != 0; i++) {
8282
const struct video_format_cap *fcap = &caps.format_caps[i];
8383
if (fcap->width_min == width && fcap->height_min == height &&
8484
fcap->pixelformat == pixformat) {
8585
break;
8686
}
87-
if (caps.format_caps[i + 1].pixelformat == NULL) {
87+
if (caps.format_caps[i + 1].pixelformat == 0) {
8888
Serial.println("The specified format is not supported");
8989
return false;
9090
}

libraries/Ethernet/examples/WebClient/WebClient.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ void loop() {
110110
Serial.print("Received ");
111111
Serial.print(byteCount);
112112
Serial.print(" bytes in ");
113-
float seconds = (float)(endMicros - beginMicros) / 1000000.0;
113+
float seconds = (endMicros - beginMicros) / 1000000.0f;
114114
Serial.print(seconds, 4);
115-
float rate = (float)byteCount / seconds / 1000.0;
116115
Serial.print(", rate = ");
116+
float rate = byteCount / 1000.0f / seconds;
117117
Serial.print(rate);
118118
Serial.print(" kbytes/second");
119119
Serial.println();

libraries/SocketWrapper/SocketHelpers.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ void NetworkInterface::setLocalIP(const IPAddress ip) {
179179
void NetworkInterface::setSubnetMask(const IPAddress subnet) {
180180
struct in_addr netmask_addr;
181181
netmask_addr.s_addr = subnet;
182+
#pragma GCC diagnostic push
183+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
184+
// TODO: store the address that was manually set and replace this call
185+
// with net_if_ipv4_set_netmask_by_addr
182186
net_if_ipv4_set_netmask(netif, &netmask_addr);
187+
#pragma GCC diagnostic pop
183188
LOG_INF("Subnet mask set: %s", subnet.toString().c_str());
184189
return;
185190
}

libraries/SocketWrapper/ZephyrUDP.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class ZephyrUDP : public arduino::UDP {
269269
IPAddress _send_to_ip;
270270
uint16_t _send_to_port;
271271
std::vector<uint8_t> _tx_data;
272-
int _rx_pkt_list_size = 10;
272+
size_t _rx_pkt_list_size = 10;
273273

274274
/* UDP RECEPTION */
275275
class UdpRxPacket {

libraries/Wire/Wire.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010

1111
// Helper function to get ZephyrI2C instance from config pointer.
1212
static arduino::ZephyrI2C *getInstance(struct i2c_target_config *config) {
13+
#pragma GCC diagnostic push
14+
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
1315
return reinterpret_cast<arduino::ZephyrI2C *>(reinterpret_cast<char *>(config) -
1416
offsetof(arduino::ZephyrI2C, i2c_cfg));
17+
#pragma GCC diagnostic pop
1518
}
1619

1720
static int i2c_target_stop_cb(struct i2c_target_config *config) {

0 commit comments

Comments
 (0)