mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
tests/cmd: simplify getting net.UnixConn
The typecast can't fail, so it doesn't make sense checking for errors here. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -99,12 +99,7 @@ func recvPidfd(socketFile string) (*os.File, error) {
|
|||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
unixconn, ok := conn.(*net.UnixConn)
|
socket, err := conn.(*net.UnixConn).File()
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to cast to unixconn")
|
|
||||||
}
|
|
||||||
|
|
||||||
socket, err := unixconn.File()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,13 +85,7 @@ func handleSingle(path string, noStdin bool) error {
|
|||||||
// Close ln, to allow for other instances to take over.
|
// Close ln, to allow for other instances to take over.
|
||||||
ln.Close()
|
ln.Close()
|
||||||
|
|
||||||
// Get the fd of the connection.
|
socket, err := conn.(*net.UnixConn).File()
|
||||||
unixconn, ok := conn.(*net.UnixConn)
|
|
||||||
if !ok {
|
|
||||||
return errors.New("failed to cast to unixconn")
|
|
||||||
}
|
|
||||||
|
|
||||||
socket, err := unixconn.File()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -158,13 +152,7 @@ func handleNull(path string) error {
|
|||||||
// Don't leave references lying around.
|
// Don't leave references lying around.
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
// Get the fd of the connection.
|
socket, err := conn.(*net.UnixConn).File()
|
||||||
unixconn, ok := conn.(*net.UnixConn)
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
socket, err := unixconn.File()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user