fixup/test compiler warnings

This commit is contained in:
graham sanderson 2021-05-24 12:17:14 -05:00 committed by Graham Sanderson
parent 4f64f3af80
commit 7e4e3290d5
10 changed files with 23 additions and 8 deletions

View File

@ -19,6 +19,12 @@ add_subdirectory(blink)
# Add hello world example # Add hello world example
add_subdirectory(hello_world) add_subdirectory(hello_world)
add_compile_options(-Wall
-Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
-Wno-unused-function # we have some for the docs that aren't called
-Wno-maybe-uninitialized
)
# Hardware-specific examples in subdirectories: # Hardware-specific examples in subdirectories:
add_subdirectory(adc) add_subdirectory(adc)
add_subdirectory(clocks) add_subdirectory(clocks)

View File

@ -144,7 +144,7 @@ int main() {
lcd_init(); lcd_init();
static uint8_t *message[] = static char *message[] =
{ {
"RP2040 by", "Raspberry Pi", "RP2040 by", "Raspberry Pi",
"A brand new", "microcontroller", "A brand new", "microcontroller",

View File

@ -37,7 +37,7 @@ int32_t fibonacci(int32_t n) {
if (n == 0) return 0; if (n == 0) return 0;
if (n == 1) return 1; if (n == 1) return 1;
int n1 = 0, n2 = 1, n3; int n1 = 0, n2 = 1, n3 = 0;
for (int i = 2; i <= n; i++) { for (int i = 2; i <= n; i++) {
n3 = n1 + n2; n3 = n1 + n2;

View File

@ -50,7 +50,7 @@ int32_t fibonacci(int32_t n) {
if (n == 0) return 0; if (n == 0) return 0;
if (n == 1) return 1; if (n == 1) return 1;
int n1 = 0, n2 = 1, n3; int n1 = 0, n2 = 1, n3 = 0;
for (int i = 2; i <= n; i++) { for (int i = 2; i <= n; i++) {
n3 = n1 + n2; n3 = n1 + n2;

View File

@ -32,7 +32,11 @@ void pio_i2c_rx_enable(PIO pio, uint sm, bool en) {
static inline void pio_i2c_put16(PIO pio, uint sm, uint16_t data) { static inline void pio_i2c_put16(PIO pio, uint sm, uint16_t data) {
while (pio_sm_is_tx_fifo_full(pio, sm)) while (pio_sm_is_tx_fifo_full(pio, sm))
; ;
// some versions of GCC dislike this
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
*(io_rw_16 *)&pio->txf[sm] = data; *(io_rw_16 *)&pio->txf[sm] = data;
#pragma GCC diagnostic pop
} }
@ -43,7 +47,11 @@ void pio_i2c_put_or_err(PIO pio, uint sm, uint16_t data) {
return; return;
if (pio_i2c_check_error(pio, sm)) if (pio_i2c_check_error(pio, sm))
return; return;
// some versions of GCC dislike this
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
*(io_rw_16 *)&pio->txf[sm] = data; *(io_rw_16 *)&pio->txf[sm] = data;
#pragma GCC diagnostic pop
} }
uint8_t pio_i2c_get(PIO pio, uint sm) { uint8_t pio_i2c_get(PIO pio, uint sm) {

View File

@ -66,6 +66,7 @@ int main() {
queue_free(&sample_fifo); queue_free(&sample_fifo);
printf("Done\n"); printf("Done\n");
return 0;
} }
bool timer_callback(repeating_timer_t *rt) { bool timer_callback(repeating_timer_t *rt) {

View File

@ -51,7 +51,7 @@ int main() {
// Actually, we want a different speed // Actually, we want a different speed
// The call will return the actual baud rate selected, which will be as close as // The call will return the actual baud rate selected, which will be as close as
// possible to that requested // possible to that requested
int actual = uart_set_baudrate(UART_ID, BAUD_RATE); int __unused actual = uart_set_baudrate(UART_ID, BAUD_RATE);
// Set UART flow control CTS/RTS, we don't want these, so turn them off // Set UART flow control CTS/RTS, we don't want these, so turn them off
uart_set_hw_flow(UART_ID, false, false); uart_set_hw_flow(UART_ID, false, false);

View File

@ -134,7 +134,7 @@ void hid_task(void) {
static bool has_key = false; static bool has_key = false;
static bool toggle = false; static bool toggle = false;
if (toggle = !toggle) { if ((toggle = !toggle)) {
uint8_t keycode[6] = {0}; uint8_t keycode[6] = {0};
keycode[0] = HID_KEY_A; keycode[0] = HID_KEY_A;

View File

@ -113,7 +113,7 @@ struct usb_endpoint_configuration *usb_get_endpoint_configuration(uint8_t addr)
*/ */
uint8_t usb_prepare_string_descriptor(const unsigned char *str) { uint8_t usb_prepare_string_descriptor(const unsigned char *str) {
// 2 for bLength + bDescriptorType + strlen * 2 because string is unicode. i.e. other byte will be 0 // 2 for bLength + bDescriptorType + strlen * 2 because string is unicode. i.e. other byte will be 0
uint8_t bLength = 2 + (strlen(str) * 2); uint8_t bLength = 2 + (strlen((const char *)str) * 2);
static const uint8_t bDescriptorType = 0x03; static const uint8_t bDescriptorType = 0x03;
volatile uint8_t *buf = &ep0_buf[0]; volatile uint8_t *buf = &ep0_buf[0];

View File

@ -129,8 +129,8 @@ static const unsigned char lang_descriptor[] = {
}; };
static const unsigned char *descriptor_strings[] = { static const unsigned char *descriptor_strings[] = {
"Raspberry Pi", // Vendor (unsigned char *) "Raspberry Pi", // Vendor
"Pico Test Device" // Product (unsigned char *) "Pico Test Device" // Product
}; };
#endif #endif