Fix nogo tests in //pkg/sentry/socket/...

PiperOrigin-RevId: 338784921
This commit is contained in:
Ting-Yu Wang 2020-10-23 19:22:07 -07:00 committed by gVisor bot
parent 3ed8ace871
commit 8dfbec28a4
7 changed files with 13 additions and 30 deletions

View File

@ -36,9 +36,9 @@ type SCMRightsVFS2 interface {
Files(ctx context.Context, max int) (rf RightsFilesVFS2, truncated bool)
}
// RightsFilesVFS2 represents a SCM_RIGHTS socket control message. A reference is
// maintained for each vfs.FileDescription and is release either when an FD is created or
// when the Release method is called.
// RightsFilesVFS2 represents a SCM_RIGHTS socket control message. A reference
// is maintained for each vfs.FileDescription and is release either when an FD
// is created or when the Release method is called.
//
// +stateify savable
type RightsFilesVFS2 []*vfs.FileDescription

View File

@ -430,18 +430,18 @@ func (s *Stack) Statistics(stat interface{}, arg string) error {
}
if rawLine == "" {
return fmt.Errorf("Failed to get raw line")
return fmt.Errorf("failed to get raw line")
}
parts := strings.SplitN(rawLine, ":", 2)
if len(parts) != 2 {
return fmt.Errorf("Failed to get prefix from: %q", rawLine)
return fmt.Errorf("failed to get prefix from: %q", rawLine)
}
sliceStat = toSlice(stat)
fields := strings.Fields(strings.TrimSpace(parts[1]))
if len(fields) != len(sliceStat) {
return fmt.Errorf("Failed to parse fields: %q", rawLine)
return fmt.Errorf("failed to parse fields: %q", rawLine)
}
if _, ok := stat.(*inet.StatSNMPTCP); ok {
snmpTCP = true
@ -457,7 +457,7 @@ func (s *Stack) Statistics(stat interface{}, arg string) error {
sliceStat[i], err = strconv.ParseUint(fields[i], 10, 64)
}
if err != nil {
return fmt.Errorf("Failed to parse field %d from: %q, %v", i, rawLine, err)
return fmt.Errorf("failed to parse field %d from: %q, %v", i, rawLine, err)
}
}

View File

@ -71,7 +71,7 @@ func (tcpMarshaler) unmarshal(buf []byte, filter stack.IPHeaderFilter) (stack.Ma
}
if filter.Protocol != header.TCPProtocolNumber {
return nil, fmt.Errorf("TCP matching is only valid for protocol %d.", header.TCPProtocolNumber)
return nil, fmt.Errorf("TCP matching is only valid for protocol %d", header.TCPProtocolNumber)
}
return &TCPMatcher{

View File

@ -68,7 +68,7 @@ func (udpMarshaler) unmarshal(buf []byte, filter stack.IPHeaderFilter) (stack.Ma
}
if filter.Protocol != header.UDPProtocolNumber {
return nil, fmt.Errorf("UDP matching is only valid for protocol %d.", header.UDPProtocolNumber)
return nil, fmt.Errorf("UDP matching is only valid for protocol %d", header.UDPProtocolNumber)
}
return &UDPMatcher{

View File

@ -36,9 +36,9 @@ type commandKind int
const (
kindNew commandKind = 0x0
kindDel = 0x1
kindGet = 0x2
kindSet = 0x3
kindDel commandKind = 0x1
kindGet commandKind = 0x2
kindSet commandKind = 0x3
)
func typeKind(typ uint16) commandKind {

View File

@ -487,7 +487,7 @@ func (q *streamQueueReceiver) Recv(ctx context.Context, data [][]byte, wantCreds
c := q.control.Clone()
// Don't consume data since we are peeking.
copied, data, _ = vecCopy(data, q.buffer)
copied, _, _ = vecCopy(data, q.buffer)
return copied, copied, c, false, q.addr, notify, nil
}

View File

@ -410,23 +410,6 @@ func init() {
"pkg/sentry/mm/special_mappable.go:80",
"pkg/sentry/platform/systrap/subprocess.go:370",
"pkg/sentry/platform/systrap/usertrap/usertrap_amd64.go:124",
"pkg/sentry/socket/control/control.go:260",
"pkg/sentry/socket/control/control.go:94",
"pkg/sentry/socket/control/control_vfs2.go:37",
"pkg/sentry/socket/hostinet/stack.go:433",
"pkg/sentry/socket/hostinet/stack.go:438",
"pkg/sentry/socket/hostinet/stack.go:444",
"pkg/sentry/socket/hostinet/stack.go:460",
"pkg/sentry/socket/netfilter/tcp_matcher.go:74",
"pkg/sentry/socket/netfilter/udp_matcher.go:71",
"pkg/sentry/socket/netlink/route/protocol.go:38",
"pkg/sentry/socket/socket.go:332",
"pkg/sentry/socket/unix/transport/connectioned.go:394",
"pkg/sentry/socket/unix/transport/connectionless.go:152",
"pkg/sentry/socket/unix/transport/unix.go:436",
"pkg/sentry/socket/unix/transport/unix.go:490",
"pkg/sentry/socket/unix/transport/unix.go:685",
"pkg/sentry/socket/unix/transport/unix.go:795",
"pkg/sentry/syscalls/linux/sys_sem.go:62",
"pkg/sentry/syscalls/linux/sys_time.go:189",
"pkg/sentry/usage/cpu.go:42",