[uaccess] Add explicit casts to and from userptr_t where needed

Allow for the possibility of userptr_t becoming a pointer type by
adding explicit casts where necessary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-04-20 13:39:32 +01:00
parent 63d27c6311
commit 71174e19d8
6 changed files with 10 additions and 10 deletions
+3 -3
View File
@@ -96,10 +96,10 @@ UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) {
* identity-mapped.
*/
if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) )
return phys_addr;
return ( ( userptr_t ) phys_addr );
/* In a 32-bit build, subtract virt_offset */
return ( phys_addr - virt_offset );
return ( ( userptr_t ) ( phys_addr - virt_offset ) );
}
/**
@@ -111,7 +111,7 @@ UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) {
*/
static inline __always_inline unsigned long
UACCESS_INLINE ( librm, user_to_phys ) ( userptr_t userptr, off_t offset ) {
unsigned long addr = ( userptr + offset );
unsigned long addr = ( ( unsigned long ) ( userptr + offset ) );
/* In a 64-bit build, any virtual address in the low 4GB is
* directly usable as a physical address, since the low 4GB is
@@ -45,7 +45,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define EM_ALIGN ( 4 * 1024 )
/** Equivalent of NOWHERE for user pointers */
#define UNOWHERE ( ~UNULL )
#define UNOWHERE ( ( userptr_t ) ~( ( intptr_t ) 0 ) )
/** An external memory block */
struct external_memory {