From c67a9331a4f7c25df943ff821c9c6ed8013df869 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 1 Aug 2018 13:19:54 +0200 Subject: gometalinter: clean up some errcheck warnings Check some errors where relevant. Unfortunately enabling errcheck does not look feasible, too many warnings. Update #538 --- pkg/host/host_linux.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'pkg/host/host_linux.go') diff --git a/pkg/host/host_linux.go b/pkg/host/host_linux.go index 38b2461f1..6d7c9c516 100644 --- a/pkg/host/host_linux.go +++ b/pkg/host/host_linux.go @@ -337,8 +337,8 @@ func checkCoverage() string { return "" } -func checkComparisons() string { - if reason := checkDebugFS(); reason != "" { +func checkComparisons() (reason string) { + if reason = checkDebugFS(); reason != "" { return reason } // TODO(dvyukov): this should run under target arch. @@ -365,7 +365,11 @@ func checkComparisons() string { if err != nil { return fmt.Sprintf("KCOV mmap failed: %v", err) } - defer syscall.Munmap(mem) + defer func() { + if err := syscall.Munmap(mem); err != nil { + reason = fmt.Sprintf("munmap failed: %v", err) + } + }() _, _, errno = syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), linux.KCOV_ENABLE, linux.KCOV_TRACE_CMP) if errno != 0 { @@ -374,7 +378,12 @@ func checkComparisons() string { } return fmt.Sprintf("ioctl(KCOV_TRACE_CMP) failed: %v", errno) } - defer syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), linux.KCOV_DISABLE, 0) + defer func() { + _, _, errno = syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), linux.KCOV_DISABLE, 0) + if errno != 0 { + reason = fmt.Sprintf("ioctl(KCOV_DISABLE) failed: %v", errno) + } + }() return "" } -- cgit mrf-deployment