slirp: Fix compiler warning for w64
PATCH 1/1 slirp: Fix compiler warning for w64
Casting a pointer to an integer value must use uintptr_t or intptr_t (not long) for portable code. MinGW-w64 requires this because sizeof(long) != sizeof(void *) for w64 hosts, so casting to long raises a compiler warning.
I use uintptr_t instead of intptr_t because changing the sign does not matter here and casting pointers to unsigned values seems more reasonable (the unsigned value is a non negative offset.
--- slirp/cksum.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
slirp/cksum.c +1 -1
@@ -75,7 +75,7 @@ int cksum(struct mbuf *m, int len)/* * Force to even boundary. */ -if ((1 & (long ) w) && (mlen >0 )) { +if ((1 & (uintptr_t )w) && (mlen >0 )) {REDUCE ; sum <<=8 ; s_util.c[0 ] = *(uint8_t *)w;
Signature · 1 line
1.7.9
Quoted 20 lines · Stefan Weil
Casting a pointer to an integer value must use
uintptr_torintptr_t(not long) for portable code. MinGW-w64 requires this because sizeof(long) !=sizeof(void *)for w64 hosts, so casting to long raises a compiler warning.I use
uintptr_tinstead ofintptr_tbecause changing the sign does not matter here and casting pointers to unsigned values seems more reasonable (the unsigned value is a non negative offset.Cc Jan Kiszka <[email protected]>Signed-off-by Stefan Weil <[email protected]>--- slirp/cksum.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)slirp/cksum.c +0
-0
slirp/cksum.c int cksum(struct mbuf *m, int len) · line 81
Quoted 8 lines
slirp/cksum.c +1
-1@@ -75,7 +75,7 @@ int cksum(struct mbuf *m, int len)/* * Force to even boundary. */ -if ((1 & (long ) w) && (mlen >0 )) { +if ((1 & (uintptr_t )w) && (mlen >0 )) {REDUCE ; sum <<=8 ; s_util.c[0 ] = *(uint8_t *)w;
Thanks, I picked this up for the slirp queue for which I will send a pull request later today.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux