From 39302300d91e4875a2e2f475bb7938dfc86a5e20 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 3 May 2018 14:01:48 +0200 Subject: gometalinter: check unkeyed composite literals Update #538 --- .gometalinter.json | 3 +-- pkg/compiler/types.go | 5 ++++- pkg/db/db.go | 2 +- prog/rand.go | 22 +++++++++++----------- sys/syz-sysgen/sysgen.go | 2 +- syz-fuzzer/fuzzer.go | 2 +- vm/gce/gce.go | 2 +- vm/qemu/qemu.go | 4 ++-- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.gometalinter.json b/.gometalinter.json index 4ca7214c3..9c58185f5 100644 --- a/.gometalinter.json +++ b/.gometalinter.json @@ -25,7 +25,6 @@ "exported .* should have comment", "comment on exported type", "comment on .* should be of the form", - "should not use dot imports", - "composite literal uses unkeyed fields" + "should not use dot imports" ] } diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go index c6be0d8f6..7c874130d 100644 --- a/pkg/compiler/types.go +++ b/pkg/compiler/types.go @@ -624,7 +624,10 @@ func init() { } typeStruct.Gen = func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type { s := comp.structs[t.Ident] - key := prog.StructKey{t.Ident, base.ArgDir} + key := prog.StructKey{ + Name: t.Ident, + Dir: base.ArgDir, + } desc := comp.structDescs[key] if desc == nil { // Need to assign to structDescs before calling genStructDesc to break recursion. diff --git a/pkg/db/db.go b/pkg/db/db.go index 1e8eb9951..ab609c513 100644 --- a/pkg/db/db.go +++ b/pkg/db/db.go @@ -255,7 +255,7 @@ func deserializeRecord(r *bufio.Reader) (key string, val []byte, seq uint64, err return } if valLen != 0 { - fr := flate.NewReader(&io.LimitedReader{r, int64(valLen)}) + fr := flate.NewReader(&io.LimitedReader{R: r, N: int64(valLen)}) if val, err = ioutil.ReadAll(fr); err != nil { return } diff --git a/prog/rand.go b/prog/rand.go index 1c31468e0..0dbb23adc 100644 --- a/prog/rand.go +++ b/prog/rand.go @@ -350,17 +350,17 @@ func createIfuzzConfig(kind TextKind) *ifuzz.Config { Priv: true, Exec: true, MemRegions: []ifuzz.MemRegion{ - {0 << 12, 1 << 12}, - {1 << 12, 1 << 12}, - {2 << 12, 1 << 12}, - {3 << 12, 1 << 12}, - {4 << 12, 1 << 12}, - {5 << 12, 1 << 12}, - {6 << 12, 1 << 12}, - {7 << 12, 1 << 12}, - {8 << 12, 1 << 12}, - {9 << 12, 1 << 12}, - {0xfec00000, 0x100}, // ioapic + {Start: 0 << 12, Size: 1 << 12}, + {Start: 1 << 12, Size: 1 << 12}, + {Start: 2 << 12, Size: 1 << 12}, + {Start: 3 << 12, Size: 1 << 12}, + {Start: 4 << 12, Size: 1 << 12}, + {Start: 5 << 12, Size: 1 << 12}, + {Start: 6 << 12, Size: 1 << 12}, + {Start: 7 << 12, Size: 1 << 12}, + {Start: 8 << 12, Size: 1 << 12}, + {Start: 9 << 12, Size: 1 << 12}, + {Start: 0xfec00000, Size: 0x100}, // ioapic }, } switch kind { diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go index f4fed8bf6..154d6ef9a 100644 --- a/sys/syz-sysgen/sysgen.go +++ b/sys/syz-sysgen/sysgen.go @@ -157,7 +157,7 @@ func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint constArr := make([]prog.ConstValue, 0, len(consts)) for name, val := range consts { - constArr = append(constArr, prog.ConstValue{name, val}) + constArr = append(constArr, prog.ConstValue{Name: name, Value: val}) } sort.Slice(constArr, func(i, j int) bool { return constArr[i].Name < constArr[j].Name diff --git a/syz-fuzzer/fuzzer.go b/syz-fuzzer/fuzzer.go index 445588008..245a65ca1 100644 --- a/syz-fuzzer/fuzzer.go +++ b/syz-fuzzer/fuzzer.go @@ -164,7 +164,7 @@ func main() { } Logf(0, "dialing manager at %v", *flagManager) - a := &ConnectArgs{*flagName} + a := &ConnectArgs{Name: *flagName} r := &ConnectRes{} if err := RPCCall(*flagManager, "Manager.Connect", a, r); err != nil { panic(err) diff --git a/vm/gce/gce.go b/vm/gce/gce.go index bdb7911f8..782712c4a 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -367,7 +367,7 @@ func (pool *Pool) waitInstanceBoot(name, ip, sshKey, sshUser, gceKey string) err if err != nil { output = []byte(fmt.Sprintf("failed to get boot output: %v", err)) } - return vmimpl.BootError{"can't ssh into the instance", output} + return vmimpl.BootError{Title: "can't ssh into the instance", Output: output} } func (pool *Pool) getSerialPortOutput(name, gceKey string) ([]byte, error) { diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index 9e27bd40c..b44f4198c 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -370,13 +370,13 @@ func (inst *instance) Boot() error { time.Sleep(time.Second) // wait for any pending output bootOutputStop <- true <-bootOutputStop - return vmimpl.BootError{"qemu stopped", bootOutput} + return vmimpl.BootError{Title: "qemu stopped", Output: bootOutput} default: } if time.Since(start) > 10*time.Minute { bootOutputStop <- true <-bootOutputStop - return vmimpl.BootError{"ssh server did not start", bootOutput} + return vmimpl.BootError{Title: "ssh server did not start", Output: bootOutput} } } bootOutputStop <- true -- cgit mrf-deployment