Skip to content

Commit

Permalink
fixup! tests: 64 bit compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fzi-haxel committed Dec 8, 2023
1 parent 7d492b3 commit 74c43df
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tests/drivers/mtd_raw/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/net/ieee802154_submac/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
25 changes: 6 additions & 19 deletions tests/periph/flashpage/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <addr> <data>\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;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/sys/events/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]");
}
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 74c43df

Please sign in to comment.