From a630fd8b418650f8df52aead511ec4d27ca48ad2 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 3 May 2018 15:48:26 +0200 Subject: gometalinter: some fixes for unparam But we still can't enable it as there are more [uninteresting] warnings. Update #538 --- pkg/compiler/compiler.go | 6 +++--- pkg/compiler/consts.go | 16 ++++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'pkg') diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index 809de5bd5..f49576561 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -176,7 +176,7 @@ func (comp *compiler) parseUnionAttrs(n *ast.Struct) (varlen bool, size uint64) } varlen = true case "size": - size = comp.parseSizeAttr(n, attr) + size = comp.parseSizeAttr(attr) default: comp.error(attr.Pos, "unknown union %v attribute %v", n.Name.Name, attr.Ident) @@ -215,7 +215,7 @@ func (comp *compiler) parseStructAttrs(n *ast.Struct) (packed bool, size, align } align = a case attr.Ident == "size": - size = comp.parseSizeAttr(n, attr) + size = comp.parseSizeAttr(attr) default: comp.error(attr.Pos, "unknown struct %v attribute %v", n.Name.Name, attr.Ident) @@ -224,7 +224,7 @@ func (comp *compiler) parseStructAttrs(n *ast.Struct) (packed bool, size, align return } -func (comp *compiler) parseSizeAttr(n *ast.Struct, attr *ast.Type) uint64 { +func (comp *compiler) parseSizeAttr(attr *ast.Type) uint64 { if len(attr.Args) != 1 { comp.error(attr.Pos, "%v attribute is expected to have 1 argument", attr.Ident) return sizeUnassigned diff --git a/pkg/compiler/consts.go b/pkg/compiler/consts.go index 1b008bd4f..79bf84e70 100644 --- a/pkg/compiler/consts.go +++ b/pkg/compiler/consts.go @@ -170,7 +170,7 @@ func (comp *compiler) patchConsts(consts map[string]uint64) { n := decl.(*ast.IntFlags) var values []*ast.Int for _, v := range n.Values { - if comp.patchIntConst(v.Pos, &v.Value, &v.Ident, consts, nil) { + if comp.patchIntConst(&v.Value, &v.Ident, consts, nil) { values = append(values, v) } } @@ -182,10 +182,9 @@ func (comp *compiler) patchConsts(consts map[string]uint64) { args []*ast.Type, _ prog.IntTypeCommon) { for i, arg := range args { if desc.Args[i].Type.Kind == kindInt { - comp.patchIntConst(arg.Pos, &arg.Value, - &arg.Ident, consts, &missing) + comp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing) if arg.HasColon { - comp.patchIntConst(arg.Pos2, &arg.Value2, + comp.patchIntConst(&arg.Value2, &arg.Ident2, consts, &missing) } } @@ -193,16 +192,14 @@ func (comp *compiler) patchConsts(consts map[string]uint64) { }) if n, ok := decl.(*ast.Resource); ok { for _, v := range n.Values { - comp.patchIntConst(v.Pos, &v.Value, - &v.Ident, consts, &missing) + comp.patchIntConst(&v.Value, &v.Ident, consts, &missing) } } if n, ok := decl.(*ast.Struct); ok { for _, attr := range n.Attrs { if attr.Ident == "size" { sz := attr.Args[0] - comp.patchIntConst(sz.Pos, &sz.Value, - &sz.Ident, consts, &missing) + comp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing) } } } @@ -227,8 +224,7 @@ func (comp *compiler) patchConsts(consts map[string]uint64) { } } -func (comp *compiler) patchIntConst(pos ast.Pos, val *uint64, id *string, - consts map[string]uint64, missing *string) bool { +func (comp *compiler) patchIntConst(val *uint64, id *string, consts map[string]uint64, missing *string) bool { if *id == "" { return true } -- cgit mrf-deployment