From: Vincenzo Frascino <vincenzo.frasc...@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.frasc...@arm.com>
Reviewed-by: Steve Capper <steve.cap...@arm.com>
Signed-off-by: Steve Capper <steve.cap...@arm.com>
---
 networking/isrv.c | 6 +++---
 networking/tftp.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/networking/isrv.c b/networking/isrv.c
index 0e3f10f9a..38466374a 100644
--- a/networking/isrv.c
+++ b/networking/isrv.c
@@ -177,9 +177,9 @@ static void handle_accept(isrv_state_t *state, int fd)
        int n, newfd;
 
        /* suppress gcc warning "cast from ptr to int of different size" */
-       fcntl(fd, F_SETFL, (int)(ptrdiff_t)(PARAM_TBL[0]) | O_NONBLOCK);
+       fcntl(fd, F_SETFL, (int)(intptr_t)(PARAM_TBL[0]) | O_NONBLOCK);
        newfd = accept(fd, NULL, 0);
-       fcntl(fd, F_SETFL, (int)(ptrdiff_t)(PARAM_TBL[0]));
+       fcntl(fd, F_SETFL, (int)(intptr_t)(PARAM_TBL[0]));
        if (newfd < 0) {
                if (errno == EAGAIN) return;
                /* Most probably someone gave us wrong fd type
@@ -285,7 +285,7 @@ void isrv_run(
        isrv_want_rd(state, listen_fd);
        /* remember flags to make blocking<->nonblocking switch faster */
        /* (suppress gcc warning "cast from ptr to int of different size") */
-       PARAM_TBL[0] = (void*)(ptrdiff_t)(fcntl(listen_fd, F_GETFL));
+       PARAM_TBL[0] = (void*)(intptr_t)(fcntl(listen_fd, F_GETFL));
 
        while (1) {
                struct timeval tv;
diff --git a/networking/tftp.c b/networking/tftp.c
index f5b4367ca..fa4f8ca63 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -586,7 +586,7 @@ static int tftp_protocol(
                case 1:
                        if (!our_lsa) {
                                /* tftp (not tftpd!) receiving 1st packet */
-                               our_lsa = ((void*)(ptrdiff_t)-1); /* not NULL */
+                               our_lsa = ((void*)(intptr_t)-1); /* not NULL */
                                len = recvfrom(socket_fd, rbuf, io_bufsize, 0,
                                                &peer_lsa->u.sa, 
&peer_lsa->len);
                                /* Our first dgram went to port 69
-- 
2.35.1

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to