unix: match ioctl req argument type to libc type

On Solaris, AIX, and zOS, the req argument of ioctl() is a signed int,
not an unsigned long like on other platforms, which means many constants
are negative, causing friction when passing them to a uint argument.
Correct the signature of these functions to pass the req argument as
signed, just like libc.

Fixes golang/go#59030.

Change-Id: Ia14e92a150f4b5fb9488c5032ca296cb786e9811
Reviewed-on: https://go-review.googlesource.com/c/sys/+/476515
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Nahum Shalman <nahamu@gmail.com>
This commit is contained in:
Jason A. Donenfeld
2023-03-17 00:07:53 +00:00
committed by Jason Donenfeld
parent d0781cc69b
commit 00d8004a14
11 changed files with 103 additions and 37 deletions
+1 -5
View File
@@ -405,17 +405,13 @@ func TestLifreqGetMTU(t *testing.T) {
if err != nil {
t.Fatalf("could not open udp socket: %v", err)
}
// SIOCGLIFMTU is negative which confuses the compiler if used inline:
// Using "unix.IoctlLifreq(ip_fd, unix.SIOCGLIFMTU, &l)" results in
// "constant -1065850502 overflows uint"
reqnum := int(unix.SIOCGLIFMTU)
var l unix.Lifreq
for link, mtu := range tc {
err = l.SetName(link)
if err != nil {
t.Fatalf("Lifreq.SetName(%q) failed: %v", link, err)
}
if err = unix.IoctlLifreq(ip_fd, uint(reqnum), &l); err != nil {
if err = unix.IoctlLifreq(ip_fd, unix.SIOCGLIFMTU, &l); err != nil {
t.Fatalf("unable to SIOCGLIFMTU: %v", err)
}
m := l.GetLifruUint()