From 8c8b47c0c8cd80d1ff64780b9893d068439ead14 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Tue, 10 Sep 2024 12:34:20 +0200 Subject: all: follow new linter recommendations --- prog/encoding.go | 12 ++++++++---- prog/hints_test.go | 2 +- prog/prio.go | 16 ++++++++++------ 3 files changed, 19 insertions(+), 11 deletions(-) (limited to 'prog') diff --git a/prog/encoding.go b/prog/encoding.go index af0bccfc0..b614e247e 100644 --- a/prog/encoding.go +++ b/prog/encoding.go @@ -56,6 +56,10 @@ type serializer struct { verbose bool } +func (ctx *serializer) print(text string) { + ctx.printf("%v", text) +} + func (ctx *serializer) printf(text string, args ...interface{}) { fmt.Fprintf(ctx.buf, text, args...) } @@ -81,7 +85,7 @@ func (ctx *serializer) call(c *Call) { } ctx.arg(a) } - ctx.printf(")") + ctx.print(")") anyChangedProps := false c.Props.ForeachProp(func(name, key string, value reflect.Value) { @@ -91,13 +95,13 @@ func (ctx *serializer) call(c *Call) { } if !anyChangedProps { - ctx.printf(" (") + ctx.print(" (") anyChangedProps = true } else { - ctx.printf(", ") + ctx.print(", ") } - ctx.printf(key) + ctx.print(key) switch kind := value.Kind(); kind { case reflect.Int: ctx.printf(": %d", value.Int()) diff --git a/prog/hints_test.go b/prog/hints_test.go index 44c24bfb8..ad525b71b 100644 --- a/prog/hints_test.go +++ b/prog/hints_test.go @@ -319,7 +319,7 @@ func TestHintsCheckDataArg(t *testing.T) { s += fmt.Sprintf("0x%x, ", x) } s += "]\n" - t.Fatalf(s) + t.Fatal(s) } }) } diff --git a/prog/prio.go b/prog/prio.go index ca4e11de4..142ad36b4 100644 --- a/prog/prio.go +++ b/prog/prio.go @@ -84,7 +84,7 @@ func (target *Target) calcResourceUsage() map[string]map[int]weights { switch a := t.(type) { case *ResourceType: if target.AuxResources[a.Desc.Name] { - noteUsage(uses, c, 1, ctx.Dir, "res%v", a.Desc.Name) + noteUsagef(uses, c, 1, ctx.Dir, "res%v", a.Desc.Name) } else { str := "res" for i, k := range a.Desc.Kind { @@ -98,20 +98,20 @@ func (target *Target) calcResourceUsage() map[string]map[int]weights { } case *PtrType: if _, ok := a.Elem.(*StructType); ok { - noteUsage(uses, c, 10, ctx.Dir, "ptrto-%v", a.Elem.Name()) + noteUsagef(uses, c, 10, ctx.Dir, "ptrto-%v", a.Elem.Name()) } if _, ok := a.Elem.(*UnionType); ok { - noteUsage(uses, c, 10, ctx.Dir, "ptrto-%v", a.Elem.Name()) + noteUsagef(uses, c, 10, ctx.Dir, "ptrto-%v", a.Elem.Name()) } if arr, ok := a.Elem.(*ArrayType); ok { - noteUsage(uses, c, 10, ctx.Dir, "ptrto-%v", arr.Elem.Name()) + noteUsagef(uses, c, 10, ctx.Dir, "ptrto-%v", arr.Elem.Name()) } case *BufferType: switch a.Kind { case BufferBlobRand, BufferBlobRange, BufferText, BufferCompressed: case BufferString, BufferGlob: if a.SubKind != "" { - noteUsage(uses, c, 2, ctx.Dir, fmt.Sprintf("str-%v", a.SubKind)) + noteUsagef(uses, c, 2, ctx.Dir, "str-%v", a.SubKind) } case BufferFilename: noteUsage(uses, c, 10, DirIn, "filename") @@ -137,7 +137,11 @@ type weights struct { inout int32 } -func noteUsage(uses map[string]map[int]weights, c *Syscall, weight int32, dir Dir, str string, args ...interface{}) { +func noteUsage(uses map[string]map[int]weights, c *Syscall, weight int32, dir Dir, str string) { + noteUsagef(uses, c, weight, dir, "%v", str) +} + +func noteUsagef(uses map[string]map[int]weights, c *Syscall, weight int32, dir Dir, str string, args ...interface{}) { id := fmt.Sprintf(str, args...) if uses[id] == nil { uses[id] = make(map[int]weights) -- cgit mrf-deployment