diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-06-06 11:34:20 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-06-07 10:41:01 +0200 |
| commit | 3f04838a10346e60b9dd81f0adb47c2518486d28 (patch) | |
| tree | 76348cbffe82c8126b2f01ad5e1b6d757c1d3007 /tools/syz-check | |
| parent | cdf1aa4dc338ddd37917942e7d6b992f4e079a00 (diff) | |
.golangci.yml: make goconst checker more strict
Diffstat (limited to 'tools/syz-check')
| -rw-r--r-- | tools/syz-check/check.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/syz-check/check.go b/tools/syz-check/check.go index 3c12ba3da..a94090a6a 100644 --- a/tools/syz-check/check.go +++ b/tools/syz-check/check.go @@ -541,9 +541,14 @@ func isNetlinkPolicy(fields []prog.Field) bool { return haveAttr } +const ( + nlattrT = "nlattr_t" + nlattrTT = "nlattr_tt" +) + func isNlattr(typ prog.Type) bool { name := typ.TemplateName() - return name == "nlattr_t" || name == "nlattr_tt" + return name == nlattrT || name == nlattrTT } func checkNetlinkPolicy(structMap map[string]prog.Type, typ prog.Type, fields []prog.Field, @@ -586,7 +591,7 @@ func checkNetlinkPolicy(structMap map[string]prog.Type, typ prog.Type, fields [] func checkNetlinkAttr(typ *prog.StructType, policy nlaPolicy) string { payload := typ.Fields[2].Type - if typ.TemplateName() == "nlattr_tt" { + if typ.TemplateName() == nlattrTT { payload = typ.Fields[4].Type } if warn := checkAttrType(typ, payload, policy); warn != "" { @@ -657,11 +662,11 @@ func checkAttrType(typ *prog.StructType, payload prog.Type, policy nlaPolicy) st return "expect string" } case NLA_NESTED: - if typ.TemplateName() != "nlattr_tt" || typ.Fields[3].Type.(*prog.ConstType).Val != 1 { + if typ.TemplateName() != nlattrTT || typ.Fields[3].Type.(*prog.ConstType).Val != 1 { return "should be nlnest" } case NLA_BITFIELD32: - if typ.TemplateName() != "nlattr_t" || payload.TemplateName() != "nla_bitfield32" { + if typ.TemplateName() != nlattrT || payload.TemplateName() != "nla_bitfield32" { return "should be nlattr[nla_bitfield32]" } case NLA_NESTED_ARRAY, NLA_REJECT: |
