diff options
author | Jeff Bean <bean@uber.com> | 2018-06-27 10:31:26 -0700 |
---|---|---|
committer | Jeff Bean <bean@uber.com> | 2018-06-27 10:31:26 -0700 |
commit | 00a3b726dd9f81474df867b834d67b25e9d6ade4 (patch) | |
tree | d6eb0f31a6ba0ac571177934bdb26e07de37e115 /server/sockopt_linux.go | |
parent | 29d0e59af48c843b686f6a77c3cb7f34fc59568d (diff) |
Fixing staticcheck errors from linux files
Diffstat (limited to 'server/sockopt_linux.go')
-rw-r--r-- | server/sockopt_linux.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/server/sockopt_linux.go b/server/sockopt_linux.go index 336caf15..9fe02ba5 100644 --- a/server/sockopt_linux.go +++ b/server/sockopt_linux.go @@ -32,10 +32,12 @@ const ( type tcpmd5sig struct { ss_family uint16 ss [126]byte - pad1 uint16 - keylen uint16 - pad2 uint32 - key [80]byte + // padding the struct + _ uint16 + keylen uint16 + // padding the struct + _ uint32 + key [80]byte } func buildTcpMD5Sig(address string, key string) (tcpmd5sig, error) { @@ -66,10 +68,11 @@ func setsockoptTcpMD5Sig(fd int, address string, key string) error { func SetTcpMD5SigSockopt(l *net.TCPListener, address string, key string) error { fi, _, err := extractFileAndFamilyFromTCPListener(l) - defer fi.Close() if err != nil { return err } + defer fi.Close() + return setsockoptTcpMD5Sig(int(fi.Fd()), address, key) } @@ -85,19 +88,21 @@ func setsockoptIpTtl(fd int, family int, value int) error { func SetListenTcpTTLSockopt(l *net.TCPListener, ttl int) error { fi, family, err := extractFileAndFamilyFromTCPListener(l) - defer fi.Close() if err != nil { return err } + defer fi.Close() + return setsockoptIpTtl(int(fi.Fd()), family, ttl) } func SetTcpTTLSockopt(conn *net.TCPConn, ttl int) error { fi, family, err := extractFileAndFamilyFromTCPConn(conn) - defer fi.Close() if err != nil { return err } + defer fi.Close() + return setsockoptIpTtl(int(fi.Fd()), family, ttl) } @@ -113,10 +118,11 @@ func setsockoptIpMinTtl(fd int, family int, value int) error { func SetTcpMinTTLSockopt(conn *net.TCPConn, ttl int) error { fi, family, err := extractFileAndFamilyFromTCPConn(conn) - defer fi.Close() if err != nil { return err } + defer fi.Close() + return setsockoptIpMinTtl(int(fi.Fd()), family, ttl) } |