From b47fe8d958bc5bb8432cb9c0aaca0f7962d02a64 Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Sat, 25 Jun 2022 22:46:47 +0800 Subject: [PATCH] fix warning in 64bit cpu --- common/usb_mem.h | 14 +++++++------- core/usbd_core.c | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/common/usb_mem.h b/common/usb_mem.h index 3806696c..6f8b2422 100644 --- a/common/usb_mem.h +++ b/common/usb_mem.h @@ -36,7 +36,7 @@ #endif #define usb_malloc(size) malloc(size) -#define usb_free(ptr) free(ptr) +#define usb_free(ptr) free(ptr) #ifdef CONFIG_USB_DCACHE_ENABLE static inline void *usb_iomalloc(size_t size) @@ -60,14 +60,14 @@ static inline void *usb_iomalloc(size_t size) ptr = usb_malloc(align_size); if (ptr != NULL) { /* the allocated memory block is aligned */ - if (((uint32_t)ptr & (align - 1)) == 0) { - align_ptr = (void *)((uint32_t)ptr + align); + if (((unsigned long)ptr & (align - 1)) == 0) { + align_ptr = (void *)((unsigned long)ptr + align); } else { - align_ptr = (void *)(((uint32_t)ptr + (align - 1)) & ~(align - 1)); + align_ptr = (void *)(((unsigned long)ptr + (align - 1)) & ~(align - 1)); } /* set the pointer before alignment pointer to the real pointer */ - *((uint32_t *)((uint32_t)align_ptr - sizeof(void *))) = (uint32_t)ptr; + *((unsigned long *)((unsigned long)align_ptr - sizeof(void *))) = (unsigned long)ptr; ptr = align_ptr; } @@ -79,12 +79,12 @@ static inline void usb_iofree(void *ptr) { void *real_ptr; - real_ptr = (void *)*(uint32_t *)((uint32_t)ptr - sizeof(void *)); + real_ptr = (void *)*(unsigned long *)((unsigned long)ptr - sizeof(void *)); usb_free(real_ptr); } #else #define usb_iomalloc(size) usb_malloc(size) -#define usb_iofree(ptr) usb_free(ptr) +#define usb_iofree(ptr) usb_free(ptr) #endif #endif diff --git a/core/usbd_core.c b/core/usbd_core.c index c80df15c..cfc7aaa5 100644 --- a/core/usbd_core.c +++ b/core/usbd_core.c @@ -311,7 +311,7 @@ static bool usbd_get_descriptor(uint16_t type_index, uint8_t **data, uint32_t *l *data = p; /* get length from structure */ - if ((type == USB_DESCRIPTOR_TYPE_CONFIGURATION)||((type == USB_DESCRIPTOR_TYPE_OTHER_SPEED))){ + if ((type == USB_DESCRIPTOR_TYPE_CONFIGURATION) || ((type == USB_DESCRIPTOR_TYPE_OTHER_SPEED))) { /* configuration descriptor is an * exception, length is at offset * 2 and 3 @@ -1056,7 +1056,7 @@ static void usbd_ep0_setup_handler(void) setup->wLength); #ifdef CONFIG_USB_DCACHE_ENABLE /* check if the data buf addr uses usbd_core_cfg.req_data */ - if (((uint32_t)usbd_core_cfg.ep0_data_buf) != ((uint32_t)usbd_core_cfg.req_data)) { + if (((unsigned long)usbd_core_cfg.ep0_data_buf) != ((unsigned long)usbd_core_cfg.req_data)) { /*copy data buf from misalign32 addr to align32 addr*/ memcpy(usbd_core_cfg.req_data, usbd_core_cfg.ep0_data_buf, usbd_core_cfg.ep0_data_buf_residue); usbd_core_cfg.ep0_data_buf = usbd_core_cfg.req_data; @@ -1251,11 +1251,11 @@ void usbd_event_notify_handler(uint8_t event, void *arg) break; case USBD_EVENT_EP_IN_NOTIFY: - usbd_ep_in_handler((uint8_t)arg); + usbd_ep_in_handler((uint8_t)(unsigned long)arg); break; case USBD_EVENT_EP_OUT_NOTIFY: - usbd_ep_out_handler((uint8_t)arg); + usbd_ep_out_handler((uint8_t)(unsigned long)arg); break; default: