[PATCH 4/9] get_console: Replace ptrdiff_t with intptr_t in xioclt()

Steve Capper steve.capper at arm.com
Mon Apr 4 10:49:57 UTC 2022


From: Vincenzo Frascino <vincenzo.frascino at arm.com>

The use of ptrdiff_t can trigger a warning because a successive cast to
void * can generate a pointer that cannot be dereferenced.

Replace it with intptr_t that does not require provenance since being an
integer is always valid.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino at arm.com>
Reviewed-by: Steve Capper <steve.capper at arm.com>
Signed-off-by: Steve Capper <steve.capper at arm.com>
---
 libbb/get_console.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libbb/get_console.c b/libbb/get_console.c
index 9044efea1..174eda874 100644
--- a/libbb/get_console.c
+++ b/libbb/get_console.c
@@ -73,6 +73,6 @@ enum {
 
 void FAST_FUNC console_make_active(int fd, const int vt_num)
 {
-	xioctl(fd, VT_ACTIVATE, (void *)(ptrdiff_t)vt_num);
-	xioctl(fd, VT_WAITACTIVE, (void *)(ptrdiff_t)vt_num);
+	xioctl(fd, VT_ACTIVATE, (void *)(intptr_t)vt_num);
+	xioctl(fd, VT_WAITACTIVE, (void *)(intptr_t)vt_num);
 }
-- 
2.35.1



More information about the busybox mailing list