From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, omni <omni+alpine@hack.org>
Subject: Re: [PATCH] tap: Explicitly cast TUNSETIFF to fix build warning with musl on ppc64le
Date: Thu, 31 Oct 2024 11:33:00 +1100 [thread overview]
Message-ID: <ZyLQPIIIgOjj_BF8@zatzit> (raw)
In-Reply-To: <20241030205030.325464-1-sbrivio@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1586 bytes --]
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@redhat.com>
Ugly, but I don't see a better way to deal with it.
Reviewed-by: David Gibson <david@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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2024-10-31 0:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-30 20:50 [PATCH] tap: Explicitly cast TUNSETIFF to fix build warning with musl on ppc64le Stefano Brivio
2024-10-31 0:33 ` David Gibson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZyLQPIIIgOjj_BF8@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=omni+alpine@hack.org \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).