On ppc64le, TUNSETIFF happens to be 2147767498, which is bigger than INT_MAX (2^31 - 1), and musl declares the second argument of ioctl() as 'int', not 'unsigned long' like glibc does, probably because of how POSIX specifies the equivalent argument, int dcmd, in posix_devctl(), so gcc reports a warning: tap.c: In function 'tap_ns_tun': tap.c:1291:24: warning: overflow in conversion from 'long unsigned int' to 'int' changes value from '2147767498' to '-2147199798' [-Woverflow] 1291 | rc = ioctl(fd, TUNSETIFF, &ifr); | ^~~~~~~~~ We don't care about that overflow, so explicitly cast TUNSETIFF to int. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- tap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tap.c b/tap.c index cfb82e9..f638f2c 100644 --- a/tap.c +++ b/tap.c @@ -1288,7 +1288,7 @@ static int tap_ns_tun(void *arg) if (fd < 0) die_perror("Failed to open() /dev/net/tun"); - rc = ioctl(fd, TUNSETIFF, &ifr); + rc = ioctl(fd, (int)TUNSETIFF, &ifr); if (rc < 0) die_perror("TUNSETIFF ioctl on /dev/net/tun failed"); -- 2.43.0
On Wed, Oct 30, 2024 at 09:50:30PM +0100, Stefano Brivio wrote:On ppc64le, TUNSETIFF happens to be 2147767498, which is bigger than INT_MAX (2^31 - 1), and musl declares the second argument of ioctl() as 'int', not 'unsigned long' like glibc does, probably because of how POSIX specifies the equivalent argument, int dcmd, in posix_devctl(), so gcc reports a warning: tap.c: In function 'tap_ns_tun': tap.c:1291:24: warning: overflow in conversion from 'long unsigned int' to 'int' changes value from '2147767498' to '-2147199798' [-Woverflow] 1291 | rc = ioctl(fd, TUNSETIFF, &ifr); | ^~~~~~~~~ We don't care about that overflow, so explicitly cast TUNSETIFF to int. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>Ugly, but I don't see a better way to deal with it. Reviewed-by: David Gibson <david(a)gibson.dropbear.id.au>--- tap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tap.c b/tap.c index cfb82e9..f638f2c 100644 --- a/tap.c +++ b/tap.c @@ -1288,7 +1288,7 @@ static int tap_ns_tun(void *arg) if (fd < 0) die_perror("Failed to open() /dev/net/tun"); - rc = ioctl(fd, TUNSETIFF, &ifr); + rc = ioctl(fd, (int)TUNSETIFF, &ifr); if (rc < 0) die_perror("TUNSETIFF ioctl on /dev/net/tun failed");-- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson