Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Dec 2020 00:27:29 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r368688 - head/sys/dev/usb
Message-ID:  <202012160027.0BG0RTBa047535@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Dec 16 00:27:28 2020
New Revision: 368688
URL: https://svnweb.freebsd.org/changeset/base/368688

Log:
  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

Modified:
  head/sys/dev/usb/usb_core.h

Modified: head/sys/dev/usb/usb_core.h
==============================================================================
--- head/sys/dev/usb/usb_core.h	Wed Dec 16 00:17:54 2020	(r368687)
+++ head/sys/dev/usb/usb_core.h	Wed Dec 16 00:27:28 2020	(r368688)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202012160027.0BG0RTBa047535>