[PATCH 8/9] mailutils: Replace ptrdiff_t with intptr_t

Steve Capper steve.capper at arm.com
Mon Apr 4 10:50:01 UTC 2022


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

The use of ptrdiff_t can trigger a warning because a successive cast to
const char * 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>
---
 mailutils/popmaildir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mailutils/popmaildir.c b/mailutils/popmaildir.c
index 1f2db2892..2d291cc9d 100644
--- a/mailutils/popmaildir.c
+++ b/mailutils/popmaildir.c
@@ -214,7 +214,7 @@ int popmaildir_main(int argc UNUSED_PARAM, char **argv)
 			monotonic_us(), (unsigned)pid, hostname);
 
 		// retrieve message in ./tmp/ unless filter is specified
-		pop3_check(retr, (const char *)(ptrdiff_t)nmsg);
+		pop3_check(retr, (const char *)(intptr_t)nmsg);
 
 #if ENABLE_FEATURE_POPMAILDIR_DELIVERY
 		// delivery helper ordered? -> setup pipe
@@ -263,7 +263,7 @@ int popmaildir_main(int argc UNUSED_PARAM, char **argv)
 
 		// delete message from server
 		if (!(opts & OPT_k))
-			pop3_check("DELE %u", (const char*)(ptrdiff_t)nmsg);
+			pop3_check("DELE %u", (const char*)(intptr_t)nmsg);
 
 		// atomically move message to ./new/
 		target = xstrdup(filename);
-- 
2.35.1



More information about the busybox mailing list