From 12b9bdd9268e8ed6fa708e8ebb6d9e1bfecb35f3 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 16 Dec 2020 00:27:28 +0000 Subject: [PATCH] Use more standard types for manipulating pointers. - Use a uintptr_t cast to get the virtual address of a pointer in USB_P2U() instead of a ptrdiff_t. - Add offsets to a char * pointer directly without roundtripping the pointer through a ptrdiff_t in USB_ADD_BYTES(). Reviewed by: imp, hselasky Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27581 --- sys/dev/usb/usb_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/usb_core.h b/sys/dev/usb/usb_core.h index c0f070a4df79..390ea56789de 100644 --- a/sys/dev/usb/usb_core.h +++ b/sys/dev/usb/usb_core.h @@ -58,11 +58,11 @@ /* helper for converting pointers to integers */ #define USB_P2U(ptr) \ - (((const uint8_t *)(ptr)) - ((const uint8_t *)0)) + ((uintptr_t)(ptr)) /* helper for computing offsets */ #define USB_ADD_BYTES(ptr,size) \ - ((void *)(USB_P2U(ptr) + (size))) + ((void *)(__DECONST(char *, (ptr)) + (size))) /* debug macro */ #define USB_ASSERT KASSERT -- 2.41.0