Skip to content
Permalink
Browse files

tests: usb: make 64-bit compatible

Let's use the PTR_DIFF() helper which performs pointer difference in a
64-bit compatible way, and use %zu for printing sizeof() results.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
  • Loading branch information...
Nicolas Pitre authored and andrewboie committed Jul 9, 2019
1 parent 755cc64 commit 9fac66ca540a7c1221d17e20ac903a647b1a0184
Showing with 7 additions and 7 deletions.
  1. +7 −7 tests/subsys/usb/desc_sections/src/desc_sections.c
@@ -205,34 +205,34 @@ static void test_desc_sections(void)
TC_PRINT("__usb_descriptor_start %p\n", __usb_descriptor_start);
TC_PRINT("__usb_descriptor_end %p\n", __usb_descriptor_end);
TC_PRINT("USB Descriptor table size %d\n",
(int)__usb_descriptor_end - (int)__usb_descriptor_start);
PTR_DIFF(__usb_descriptor_end, __usb_descriptor_start));

TC_PRINT("__usb_data_start %p\n", __usb_data_start);
TC_PRINT("__usb_data_end %p\n", __usb_data_end);
TC_PRINT("USB Configuration data size %d\n",
(int)__usb_data_end - (int)__usb_data_start);
PTR_DIFF(__usb_data_end, __usb_data_start));

TC_PRINT("sizeof usb_cfg_data %u\n", sizeof(struct usb_cfg_data));
TC_PRINT("sizeof usb_cfg_data %zu\n", sizeof(struct usb_cfg_data));

LOG_DBG("Starting logs");

LOG_HEXDUMP_DBG((u8_t *)__usb_descriptor_start,
(int)__usb_descriptor_end - (int)__usb_descriptor_start,
PTR_DIFF(__usb_descriptor_end, __usb_descriptor_start),
"USB Descriptor table section");

LOG_HEXDUMP_DBG((u8_t *)__usb_data_start,
(int)__usb_data_end - (int)__usb_data_start,
PTR_DIFF(__usb_data_end, __usb_data_start),
"USB Configuratio structures section");

head = (struct usb_desc_header *)__usb_descriptor_start;
zassert_not_null(head, NULL);

zassert_equal((int)__usb_descriptor_end - (int)__usb_descriptor_start,
zassert_equal(PTR_DIFF(__usb_descriptor_end, __usb_descriptor_start),
133, NULL);

/* Calculate number of structures */
zassert_equal(__usb_data_end - __usb_data_start, NUM_INSTANCES, NULL);
zassert_equal((int)__usb_data_end - (int)__usb_data_start,
zassert_equal(PTR_DIFF(__usb_data_end, __usb_data_start),
NUM_INSTANCES * sizeof(struct usb_cfg_data), NULL);

check_endpoint_allocation(head);

0 comments on commit 9fac66c

Please sign in to comment.
You can’t perform that action at this time.