From 3652f98a5d6c8bbe4707c5764b10e5bb9a13c370 Mon Sep 17 00:00:00 2001 From: Olivier Gay Date: Sun, 27 Oct 2013 17:05:13 +0100 Subject: [PATCH] Fix all compilation warnings --- gdbserver/gdb-server.c | 2 +- src/st-term.c | 10 ++++++++-- src/stlink-common.h | 2 +- src/stlink-usb.c | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gdbserver/gdb-server.c b/gdbserver/gdb-server.c index 69eadda..7e8bb68 100644 --- a/gdbserver/gdb-server.c +++ b/gdbserver/gdb-server.c @@ -172,7 +172,7 @@ int parse_options(int argc, char** argv, st_state_t *st) { int main(int argc, char** argv) { - uint32_t voltage; + int32_t voltage; stlink_t *sl = NULL; diff --git a/src/st-term.c b/src/st-term.c index 346cca5..bbf7ea3 100644 --- a/src/st-term.c +++ b/src/st-term.c @@ -13,6 +13,11 @@ #define STLINKY_MAGIC 0xDEADF00D +#define READ_UINT32_LE(buf) ((uint32_t) ( buf[0] \ + | buf[1] << 8 \ + | buf[2] << 16 \ + | buf[3] << 24)) + struct stlinky { stlink_t *sl; uint32_t off; @@ -26,11 +31,11 @@ struct stlinky* stlinky_detect(stlink_t* sl) static const uint32_t sram_base = 0x20000000; struct stlinky* st = malloc(sizeof(struct stlinky)); st->sl = sl; - printf("sram: 0x%x bytes @ 0x%x\n", sl->sram_base, sl->sram_size); + printf("sram: 0x%x bytes @ 0x%zx\n", sl->sram_base, sl->sram_size); uint32_t off; for (off = 0; off < sl->sram_size; off += 4) { stlink_read_mem32(sl, sram_base + off, 4); - if ( STLINKY_MAGIC== *(uint32_t*) sl->q_buf) + if (STLINKY_MAGIC == READ_UINT32_LE(sl->q_buf)) { printf("stlinky detected at 0x%x\n", sram_base + off); st->off = sram_base + off; @@ -121,6 +126,7 @@ static int keep_running = 1; static int sigcount=0; void cleanup(int dummy) { + (void) dummy; sigcount++; keep_running = 0; printf("\n\nGot a signal\n"); diff --git a/src/stlink-common.h b/src/stlink-common.h index edf8c67..5796228 100644 --- a/src/stlink-common.h +++ b/src/stlink-common.h @@ -397,7 +397,7 @@ static const chip_params_t devices[] = { void (*step) (stlink_t * stl); int (*current_mode) (stlink_t * stl); void (*force_debug) (stlink_t *sl); - uint32_t (*target_voltage) (stlink_t *sl); + int32_t (*target_voltage) (stlink_t *sl); } stlink_backend_t; struct _stlink { diff --git a/src/stlink-usb.c b/src/stlink-usb.c index fa2bd7e..ec4053a 100644 --- a/src/stlink-usb.c +++ b/src/stlink-usb.c @@ -203,7 +203,7 @@ void _stlink_usb_version(stlink_t *sl) { } } -int _stlink_usb_target_voltage(stlink_t *sl) { +int32_t _stlink_usb_target_voltage(stlink_t *sl) { struct stlink_libusb * const slu = sl->backend_data; unsigned char* const rdata = sl->q_buf; unsigned char* const cmd = sl->c_buf; -- 2.30.2