Skip to content

Commit 7e4e329

Browse files
committed
fixup/test compiler warnings
1 parent 4f64f3a commit 7e4e329

File tree

10 files changed

+23
-8
lines changed

10 files changed

+23
-8
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ add_subdirectory(blink)
1919
# Add hello world example
2020
add_subdirectory(hello_world)
2121

22+
add_compile_options(-Wall
23+
-Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
24+
-Wno-unused-function # we have some for the docs that aren't called
25+
-Wno-maybe-uninitialized
26+
)
27+
2228
# Hardware-specific examples in subdirectories:
2329
add_subdirectory(adc)
2430
add_subdirectory(clocks)

i2c/lcd_1602_i2c/lcd_1602_i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ int main() {
144144

145145
lcd_init();
146146

147-
static uint8_t *message[] =
147+
static char *message[] =
148148
{
149149
"RP2040 by", "Raspberry Pi",
150150
"A brand new", "microcontroller",

multicore/multicore_runner/multicore_runner.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int32_t fibonacci(int32_t n) {
3737
if (n == 0) return 0;
3838
if (n == 1) return 1;
3939

40-
int n1 = 0, n2 = 1, n3;
40+
int n1 = 0, n2 = 1, n3 = 0;
4141

4242
for (int i = 2; i <= n; i++) {
4343
n3 = n1 + n2;

multicore/multicore_runner_queue/multicore_runner_queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int32_t fibonacci(int32_t n) {
5050
if (n == 0) return 0;
5151
if (n == 1) return 1;
5252

53-
int n1 = 0, n2 = 1, n3;
53+
int n1 = 0, n2 = 1, n3 = 0;
5454

5555
for (int i = 2; i <= n; i++) {
5656
n3 = n1 + n2;

pio/i2c/pio_i2c.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ void pio_i2c_rx_enable(PIO pio, uint sm, bool en) {
3232
static inline void pio_i2c_put16(PIO pio, uint sm, uint16_t data) {
3333
while (pio_sm_is_tx_fifo_full(pio, sm))
3434
;
35+
// some versions of GCC dislike this
36+
#pragma GCC diagnostic push
37+
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
3538
*(io_rw_16 *)&pio->txf[sm] = data;
39+
#pragma GCC diagnostic pop
3640
}
3741

3842

@@ -43,7 +47,11 @@ void pio_i2c_put_or_err(PIO pio, uint sm, uint16_t data) {
4347
return;
4448
if (pio_i2c_check_error(pio, sm))
4549
return;
50+
// some versions of GCC dislike this
51+
#pragma GCC diagnostic push
52+
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
4653
*(io_rw_16 *)&pio->txf[sm] = data;
54+
#pragma GCC diagnostic pop
4755
}
4856

4957
uint8_t pio_i2c_get(PIO pio, uint sm) {

timer/periodic_sampler/periodic_sampler.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ int main() {
6666

6767
queue_free(&sample_fifo);
6868
printf("Done\n");
69+
return 0;
6970
}
7071

7172
bool timer_callback(repeating_timer_t *rt) {

uart/uart_advanced/uart_advanced.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int main() {
5151
// Actually, we want a different speed
5252
// The call will return the actual baud rate selected, which will be as close as
5353
// possible to that requested
54-
int actual = uart_set_baudrate(UART_ID, BAUD_RATE);
54+
int __unused actual = uart_set_baudrate(UART_ID, BAUD_RATE);
5555

5656
// Set UART flow control CTS/RTS, we don't want these, so turn them off
5757
uart_set_hw_flow(UART_ID, false, false);

usb/device/dev_hid_composite/dev_hid_composite.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void hid_task(void) {
134134
static bool has_key = false;
135135

136136
static bool toggle = false;
137-
if (toggle = !toggle) {
137+
if ((toggle = !toggle)) {
138138
uint8_t keycode[6] = {0};
139139
keycode[0] = HID_KEY_A;
140140

usb/device/dev_lowlevel/dev_lowlevel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct usb_endpoint_configuration *usb_get_endpoint_configuration(uint8_t addr)
113113
*/
114114
uint8_t usb_prepare_string_descriptor(const unsigned char *str) {
115115
// 2 for bLength + bDescriptorType + strlen * 2 because string is unicode. i.e. other byte will be 0
116-
uint8_t bLength = 2 + (strlen(str) * 2);
116+
uint8_t bLength = 2 + (strlen((const char *)str) * 2);
117117
static const uint8_t bDescriptorType = 0x03;
118118

119119
volatile uint8_t *buf = &ep0_buf[0];

usb/device/dev_lowlevel/dev_lowlevel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ static const unsigned char lang_descriptor[] = {
129129
};
130130

131131
static const unsigned char *descriptor_strings[] = {
132-
"Raspberry Pi", // Vendor
133-
"Pico Test Device" // Product
132+
(unsigned char *) "Raspberry Pi", // Vendor
133+
(unsigned char *) "Pico Test Device" // Product
134134
};
135135

136136
#endif

0 commit comments

Comments
 (0)