diff options
author | Ian Gudger <igudger@google.com> | 2018-05-08 09:51:07 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-05-08 09:51:56 -0700 |
commit | b4765f782d91443ab0415dc00e727d783632e2ad (patch) | |
tree | 82c2b45b7d9fee5ceaf3792e34c5fdf09c69da43 /pkg | |
parent | d0d01a18963ed7cfc29e5b8334e30b1234b6048b (diff) |
Fix warning: redundant if ...; err != nil check, just return error instead.
This warning is produced by golint.
PiperOrigin-RevId: 195833381
Change-Id: Idd6a7e57e3cfdf00819f2374b19fc113585dc1e1
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/bpf/decoder.go | 5 | ||||
-rw-r--r-- | pkg/compressio/compressio.go | 5 | ||||
-rw-r--r-- | pkg/p9/local_server/local_server.go | 6 | ||||
-rw-r--r-- | pkg/sentry/fs/fdpipe/pipe.go | 5 | ||||
-rw-r--r-- | pkg/sentry/fs/host/fs_test.go | 6 | ||||
-rw-r--r-- | pkg/sentry/fs/host/socket.go | 5 | ||||
-rw-r--r-- | pkg/sentry/kernel/task_signals.go | 10 | ||||
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_file.go | 7 | ||||
-rw-r--r-- | pkg/tcpip/stack/transport_demuxer.go | 6 |
9 files changed, 11 insertions, 44 deletions
diff --git a/pkg/bpf/decoder.go b/pkg/bpf/decoder.go index 6873ffa5c..ef41e9edc 100644 --- a/pkg/bpf/decoder.go +++ b/pkg/bpf/decoder.go @@ -161,10 +161,7 @@ func decodeAlu(inst linux.BPFInstruction, w *bytes.Buffer) error { default: return fmt.Errorf("invalid BPF ALU instruction: %v", inst) } - if err := decodeSource(inst, w); err != nil { - return err - } - return nil + return decodeSource(inst, w) } func decodeSource(inst linux.BPFInstruction, w *bytes.Buffer) error { diff --git a/pkg/compressio/compressio.go b/pkg/compressio/compressio.go index e0d36aee9..ef8cbd2a5 100644 --- a/pkg/compressio/compressio.go +++ b/pkg/compressio/compressio.go @@ -184,10 +184,7 @@ func handleResult(r result, callback func(*chunk) error) error { if r.err != nil { return r.err } - if err := callback(r.chunk); err != nil { - return err - } - return nil + return callback(r.chunk) } // schedule schedules the given buffers. diff --git a/pkg/p9/local_server/local_server.go b/pkg/p9/local_server/local_server.go index 5b1e97711..7a3e4cffe 100644 --- a/pkg/p9/local_server/local_server.go +++ b/pkg/p9/local_server/local_server.go @@ -246,11 +246,7 @@ func (l *local) Symlink(oldname string, newname string, _ p9.UID, _ p9.GID) (p9. // // Not properly implemented. func (l *local) Link(target p9.File, newname string) error { - if err := os.Link(target.(*local).path, path.Join(l.path, newname)); err != nil { - return err - } - - return nil + return os.Link(target.(*local).path, path.Join(l.path, newname)) } // Mknod implements p9.File.Mknod. diff --git a/pkg/sentry/fs/fdpipe/pipe.go b/pkg/sentry/fs/fdpipe/pipe.go index f7bbd4aff..7b318e35f 100644 --- a/pkg/sentry/fs/fdpipe/pipe.go +++ b/pkg/sentry/fs/fdpipe/pipe.go @@ -90,10 +90,7 @@ func (p *pipeOperations) init() error { if err := syscall.SetNonblock(p.file.FD(), true); err != nil { return err } - if err := fdnotifier.AddFD(int32(p.file.FD()), &p.Queue); err != nil { - return err - } - return nil + return fdnotifier.AddFD(int32(p.file.FD()), &p.Queue) } // EventRegister implements waiter.Waitable.EventRegister. diff --git a/pkg/sentry/fs/host/fs_test.go b/pkg/sentry/fs/host/fs_test.go index c000afc49..b08125ca8 100644 --- a/pkg/sentry/fs/host/fs_test.go +++ b/pkg/sentry/fs/host/fs_test.go @@ -141,11 +141,7 @@ func createTestDirs(ctx context.Context, t *testing.T, m *fs.MountNamespace) err return err } - if err := symlinks.CreateLink(ctx, r, "/symlinks", "recursive"); err != nil { - return err - } - - return nil + return symlinks.CreateLink(ctx, r, "/symlinks", "recursive") } // allPaths returns a slice of all paths of entries visible in the rootfs. diff --git a/pkg/sentry/fs/host/socket.go b/pkg/sentry/fs/host/socket.go index 8e36ed7ee..467633052 100644 --- a/pkg/sentry/fs/host/socket.go +++ b/pkg/sentry/fs/host/socket.go @@ -69,10 +69,7 @@ func (e *endpoint) init() error { } e.stype = unix.SockType(stype) - if err := fdnotifier.AddFD(int32(e.fd), &e.queue); err != nil { - return err - } - return nil + return fdnotifier.AddFD(int32(e.fd), &e.queue) } // newEndpoint creates a new host endpoint. diff --git a/pkg/sentry/kernel/task_signals.go b/pkg/sentry/kernel/task_signals.go index 2340256b0..e4ef7fd67 100644 --- a/pkg/sentry/kernel/task_signals.go +++ b/pkg/sentry/kernel/task_signals.go @@ -127,10 +127,7 @@ func (t *Task) dequeueSignalLocked() *arch.SignalInfo { if info := t.pendingSignals.dequeue(t.tr.SignalMask); info != nil { return info } - if info := t.tg.pendingSignals.dequeue(t.tr.SignalMask); info != nil { - return info - } - return nil + return t.tg.pendingSignals.dequeue(t.tr.SignalMask) } // TakeSignal returns a pending signal not blocked by mask. Signal handlers are @@ -144,10 +141,7 @@ func (t *Task) TakeSignal(mask linux.SignalSet) *arch.SignalInfo { if info := t.pendingSignals.dequeue(mask); info != nil { return info } - if info := t.tg.pendingSignals.dequeue(mask); info != nil { - return info - } - return nil + return t.tg.pendingSignals.dequeue(mask) } // discardSpecificLocked removes all instances of the given signal from all diff --git a/pkg/sentry/syscalls/linux/sys_file.go b/pkg/sentry/syscalls/linux/sys_file.go index a2dbba7e0..5fbacc15e 100644 --- a/pkg/sentry/syscalls/linux/sys_file.go +++ b/pkg/sentry/syscalls/linux/sys_file.go @@ -460,14 +460,11 @@ func accessAt(t *kernel.Task, dirFD kdefs.FD, addr usermem.Addr, resolve bool, m creds: creds, } - if err := d.Inode.CheckPermission(ctx, fs.PermMask{ + return d.Inode.CheckPermission(ctx, fs.PermMask{ Read: mode&rOK != 0, Write: mode&wOK != 0, Execute: mode&xOK != 0, - }); err != nil { - return err - } - return nil + }) }) } diff --git a/pkg/tcpip/stack/transport_demuxer.go b/pkg/tcpip/stack/transport_demuxer.go index 3c0d7aa31..7bb853622 100644 --- a/pkg/tcpip/stack/transport_demuxer.go +++ b/pkg/tcpip/stack/transport_demuxer.go @@ -158,9 +158,5 @@ func (d *transportDemuxer) findEndpointLocked(eps *transportEndpoints, vv *buffe // Try to find a match with only the local port. nid.LocalAddress = "" - if ep := eps.endpoints[nid]; ep != nil { - return ep - } - - return nil + return eps.endpoints[nid] } |