From db4ffada100028c7e9b796d4d90442f59db22a70 Mon Sep 17 00:00:00 2001 From: cweld510 Date: Mon, 7 Oct 2024 22:39:13 +0000 Subject: [PATCH] style feedback: remove newlines, fix import, remove stray comment --- pkg/sentry/kernel/kernel.go | 8 ++++---- pkg/sentry/socket/unix/transport/host.go | 6 +----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pkg/sentry/kernel/kernel.go b/pkg/sentry/kernel/kernel.go index 232afa40c..aa3ae8fd9 100644 --- a/pkg/sentry/kernel/kernel.go +++ b/pkg/sentry/kernel/kernel.go @@ -70,7 +70,7 @@ import ( "gvisor.dev/gvisor/pkg/sentry/pgalloc" "gvisor.dev/gvisor/pkg/sentry/platform" "gvisor.dev/gvisor/pkg/sentry/socket/netlink/port" - unixsocket "gvisor.dev/gvisor/pkg/sentry/socket/unix/transport" + "gvisor.dev/gvisor/pkg/sentry/socket/unix/transport" sentrytime "gvisor.dev/gvisor/pkg/sentry/time" "gvisor.dev/gvisor/pkg/sentry/unimpl" uspb "gvisor.dev/gvisor/pkg/sentry/unimpl/unimplemented_syscall_go_proto" @@ -390,7 +390,7 @@ type Kernel struct { lastCheckpointStatus error `state:"nosave"` // UnixSocketOpts stores configuration options for management of unix sockets. - UnixSocketOpts unixsocket.UnixSocketOpts + UnixSocketOpts transport.UnixSocketOpts } // Saver is an interface for saving the kernel. @@ -451,14 +451,14 @@ type InitKernelArgs struct { MaxFDLimit int32 // UnixSocketOpts contains configuration options for unix sockets. - UnixSocketOpts unixsocket.UnixSocketOpts + UnixSocketOpts transport.UnixSocketOpts } // Init initialize the Kernel with no tasks. // // Callers must manually set Kernel.Platform and call Kernel.SetMemoryFile // before calling Init. -func (k *Kernel) Init(args InitKernelArgs) error { // TODO (colin) propagate up +func (k *Kernel) Init(args InitKernelArgs) error { if args.Timekeeper == nil { return fmt.Errorf("args.Timekeeper is nil") } diff --git a/pkg/sentry/socket/unix/transport/host.go b/pkg/sentry/socket/unix/transport/host.go index d37a0bee5..ddb67af68 100644 --- a/pkg/sentry/socket/unix/transport/host.go +++ b/pkg/sentry/socket/unix/transport/host.go @@ -98,7 +98,6 @@ func (c *HostConnectedEndpoint) init() *syserr.Error { } func (c *HostConnectedEndpoint) initFromOptions() *syserr.Error { - if c.fd < 0 { // There is no underlying FD to restore; nothing to do return nil @@ -207,7 +206,6 @@ func (c *HostConnectedEndpoint) CloseSend() { // Preconditions: c.mu must be held. func (c *HostConnectedEndpoint) closeSendLocked() { - if c.IsSendClosed() { return } @@ -328,7 +326,6 @@ func (c *HostConnectedEndpoint) CloseRecv() { // Preconditions: c.mu must be held. func (c *HostConnectedEndpoint) closeRecvLocked() { - if c.IsRecvClosed() { return } @@ -455,7 +452,7 @@ func (e *SCMConnectedEndpoint) Release(ctx context.Context) { e.mu.Lock() defer e.mu.Unlock() - if e.fd == -1 { + if e.fd < 0 { return } @@ -464,7 +461,6 @@ func (e *SCMConnectedEndpoint) Release(ctx context.Context) { log.Warningf("Failed to close host fd %d: %v", err) } e.destroyLocked() - }) }