From 74c43df5fad1f5c8e96c06084c7ba7858020c244 Mon Sep 17 00:00:00 2001 From: Frederik Haxel Date: Fri, 8 Dec 2023 11:36:37 +0100 Subject: [PATCH] fixup! tests: 64 bit compatibility --- tests/drivers/mtd_raw/main.c | 2 +- tests/net/ieee802154_submac/main.c | 2 +- tests/periph/flashpage/main.c | 25 ++++++------------------- tests/sys/events/main.c | 8 ++++---- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/tests/drivers/mtd_raw/main.c b/tests/drivers/mtd_raw/main.c index 1252f28e86e0..8a7a03873f2b 100644 --- a/tests/drivers/mtd_raw/main.c +++ b/tests/drivers/mtd_raw/main.c @@ -279,7 +279,7 @@ static void _print_info(mtd_dev_t *dev) static int cmd_info(int argc, char **argv) { if (argc < 2) { - printf("mtd devices: %d\n", MTD_NUMOF); + printf("mtd devices: %d\n", (unsigned)MTD_NUMOF); for (unsigned i = 0; i < MTD_NUMOF; ++i) { printf(" -=[ MTD_%d ]=-\n", i); diff --git a/tests/net/ieee802154_submac/main.c b/tests/net/ieee802154_submac/main.c index c38e39e6701d..5b937bcfe243 100644 --- a/tests/net/ieee802154_submac/main.c +++ b/tests/net/ieee802154_submac/main.c @@ -344,7 +344,7 @@ static void submac_rx_done(ieee802154_submac_t *submac) printf("%u, ", (unsigned)((buffer[1] & IEEE802154_FCF_VERS_MASK) >> 4)); printf("Seq.: %u\n", (unsigned)ieee802154_get_seq(buffer)); od_hex_dump(buffer + mhr_len, data_len - mhr_len, 0); - printf("txt (%u chars): ", (unsigned)(data_len - mhr_len)); + printf("txt (%lu chars): ", (unsigned long)(data_len - mhr_len)); for (int i = mhr_len; i < data_len; i++) { if ((buffer[i] > 0x1F) && (buffer[i] < 0x80)) { putchar((char)buffer[i]); diff --git a/tests/periph/flashpage/main.c b/tests/periph/flashpage/main.c index b2e69596998d..98aecf178989 100644 --- a/tests/periph/flashpage/main.c +++ b/tests/periph/flashpage/main.c @@ -203,42 +203,29 @@ static int cmd_write(int argc, char **argv) } #endif -static uint32_t getaddr(const char *str) +static uintptr_t getaddr(const char *str) { - uint32_t addr = strtol(str, NULL, 16); + uintptr_t addr = (uintptr_t)strtol(str, NULL, 16); return addr; } static int cmd_write_raw(int argc, char **argv) { -#if (__SIZEOF_POINTER__ == 2) - uint16_t addr; -#else - uint32_t addr; -#endif + uintptr_t addr; if (argc < 3) { printf("usage: %s \n", argv[0]); return 1; } -#if (__SIZEOF_POINTER__ == 2) - addr = (uint16_t) getaddr(argv[1]); -#else addr = getaddr(argv[1]); -#endif /* try to align */ memcpy(raw_buf, argv[2], strlen(argv[2])); - flashpage_write((void*)(uintptr_t)addr, raw_buf, strlen(raw_buf)); -#if (__SIZEOF_POINTER__ == 2) - printf("wrote local data to flash address %#" PRIx16 " of len %u\n", - addr, strlen(raw_buf)); -#else - printf("wrote local data to flash address %#" PRIx32 " of len %u\n", - addr, (unsigned)strlen(raw_buf)); -#endif + flashpage_write((void*)addr, raw_buf, strlen(raw_buf)); + printf("wrote local data to flash address %#" PRIxPTR " of len %lu\n", + addr, (unsigned long)strlen(raw_buf)); return 0; } diff --git a/tests/sys/events/main.c b/tests/sys/events/main.c index 03b0c363a4ec..ed7f4442bb09 100644 --- a/tests/sys/events/main.c +++ b/tests/sys/events/main.c @@ -94,7 +94,7 @@ static void timed_callback(void *arg) uint32_t now = xtimer_now_usec(); #endif expect((now - before >= 100000LU)); - printf("triggered timed callback with arg 0x%08" PRIuPTR " after %" PRIu32 "us\n", + printf("triggered timed callback with arg 0x%08" PRIxPTR " after %" PRIu32 "us\n", (uintptr_t)arg, now - before); puts("[SUCCESS]"); } @@ -177,12 +177,12 @@ int main(void) /* test posting different kind of events in order to a statically * initialized queue */ event_queue_t queue = EVENT_QUEUE_INIT; - printf("posting 0x%08" PRIuPTR "\n", (uintptr_t)&event); + printf("posting 0x%08" PRIxPTR "\n", (uintptr_t)&event); event_post(&queue, &event); - printf("posting 0x%08" PRIuPTR "\n", (uintptr_t)&event2); + printf("posting 0x%08" PRIxPTR "\n", (uintptr_t)&event2); event_post(&queue, &event2); - printf("canceling 0x%08" PRIuPTR "\n", (uintptr_t)&event2); + printf("canceling 0x%08" PRIxPTR "\n", (uintptr_t)&event2); event_cancel(&queue, &event2); puts("posting custom event");