From 4a9fce1952b2b4742bd07bc5137c75b0225d56ab Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 28 Mar 2019 15:30:18 +0100 Subject: all: fix warnings pointed to by golangci-lint Update #977 --- pkg/compiler/consts.go | 3 +-- pkg/csource/csource_test.go | 2 +- pkg/ifuzz/ifuzz_test.go | 2 +- pkg/ipc/ipc_test.go | 2 +- pkg/repro/repro_test.go | 2 +- prog/export_test.go | 2 +- vm/adb/adb.go | 7 +++---- vm/gvisor/gvisor.go | 2 +- 8 files changed, 10 insertions(+), 12 deletions(-) diff --git a/pkg/compiler/consts.go b/pkg/compiler/consts.go index d3556c047..e06319fb6 100644 --- a/pkg/compiler/consts.go +++ b/pkg/compiler/consts.go @@ -164,10 +164,9 @@ func (comp *compiler) assignSyscallNumbers(consts map[string]uint64) { // Updates desc and returns set of unsupported syscalls and flags. func (comp *compiler) patchConsts(consts map[string]uint64) { for _, decl := range comp.desc.Nodes { - switch decl.(type) { + switch n := decl.(type) { case *ast.IntFlags: // Unsupported flag values are dropped. - n := decl.(*ast.IntFlags) var values []*ast.Int for _, v := range n.Values { if comp.patchIntConst(&v.Value, &v.Ident, consts, nil) { diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index 773ff2ed8..75e451b9b 100644 --- a/pkg/csource/csource_test.go +++ b/pkg/csource/csource_test.go @@ -60,7 +60,7 @@ func TestGenerate(t *testing.T) { } func testTarget(t *testing.T, target *prog.Target, full bool) { - seed := int64(time.Now().UnixNano()) + seed := time.Now().UnixNano() if os.Getenv("TRAVIS") != "" { seed = 0 // required for deterministic coverage reports } diff --git a/pkg/ifuzz/ifuzz_test.go b/pkg/ifuzz/ifuzz_test.go index 3758f08d2..5a9af21c6 100644 --- a/pkg/ifuzz/ifuzz_test.go +++ b/pkg/ifuzz/ifuzz_test.go @@ -36,7 +36,7 @@ func TestMode(t *testing.T) { } func TestDecode(t *testing.T) { - seed := int64(time.Now().UnixNano()) + seed := time.Now().UnixNano() if os.Getenv("TRAVIS") != "" { seed = 0 // required for deterministic coverage reports } diff --git a/pkg/ipc/ipc_test.go b/pkg/ipc/ipc_test.go index 42d066d08..22c0c96cd 100644 --- a/pkg/ipc/ipc_test.go +++ b/pkg/ipc/ipc_test.go @@ -37,7 +37,7 @@ func initTest(t *testing.T) (*prog.Target, rand.Source, int, EnvFlags) { if testing.Short() { iters = 10 } - seed := int64(time.Now().UnixNano()) + seed := time.Now().UnixNano() if os.Getenv("TRAVIS") != "" { seed = 0 // required for deterministic coverage reports } diff --git a/pkg/repro/repro_test.go b/pkg/repro/repro_test.go index c417b7416..bc6949a97 100644 --- a/pkg/repro/repro_test.go +++ b/pkg/repro/repro_test.go @@ -18,7 +18,7 @@ func initTest(t *testing.T) (*rand.Rand, int) { if testing.Short() { iters = 100 } - seed := int64(time.Now().UnixNano()) + seed := time.Now().UnixNano() if os.Getenv("TRAVIS") != "" { seed = 0 // required for deterministic coverage reports } diff --git a/prog/export_test.go b/prog/export_test.go index a49d094ef..d5c67ac70 100644 --- a/prog/export_test.go +++ b/prog/export_test.go @@ -32,7 +32,7 @@ func initTargetTest(t *testing.T, os, arch string) *Target { } func randSource(t *testing.T) rand.Source { - seed := int64(time.Now().UnixNano()) + seed := time.Now().UnixNano() if os.Getenv("TRAVIS") != "" { seed = 0 // required for deterministic coverage reports } diff --git a/vm/adb/adb.go b/vm/adb/adb.go index 433caf16d..3996ab012 100644 --- a/vm/adb/adb.go +++ b/vm/adb/adb.go @@ -328,12 +328,11 @@ func (inst *instance) getBatteryLevel(numRetry int) (int, error) { // sleep for 5 seconds before retrying time.Sleep(5 * time.Second) out, err = inst.adb("shell", "dumpsys battery | grep level:") - } else { - if err != nil { - return 0, err - } } } + if err != nil { + return 0, err + } val := 0 for _, c := range out { if c >= '0' && c <= '9' { diff --git a/vm/gvisor/gvisor.go b/vm/gvisor/gvisor.go index 6ae6151b6..306b4e418 100644 --- a/vm/gvisor/gvisor.go +++ b/vm/gvisor/gvisor.go @@ -336,7 +336,7 @@ func (inst *instance) Diagnose() ([]byte, bool) { func init() { if os.Getenv("SYZ_GVISOR_PROXY") != "" { - fmt.Fprintf(os.Stderr, initStartMsg) + fmt.Fprint(os.Stderr, initStartMsg) select {} } } -- cgit mrf-deployment