diff --git a/cmd/vet/asmdecl.go b/cmd/vet/asmdecl.go index a32f1d69..001b1770 100644 --- a/cmd/vet/asmdecl.go +++ b/cmd/vet/asmdecl.go @@ -119,8 +119,8 @@ func asmCheck(pkg *Package) { for lineno, line := range lines { lineno++ - warnf := func(format string, args ...interface{}) { - f.Warnf(token.NoPos, "%s:%d: [%s] %s", f.name, lineno, arch, fmt.Sprintf(format, args...)) + badf := func(format string, args ...interface{}) { + f.Badf(token.NoPos, "%s:%d: [%s] %s", f.name, lineno, arch, fmt.Sprintf(format, args...)) } if arch == "" { @@ -147,7 +147,7 @@ func asmCheck(pkg *Package) { if fn != nil { size, _ := strconv.Atoi(m[4]) if size != fn.size && (m[2] != "7" && !strings.Contains(m[2], "NOSPLIT") || size != 0) { - warnf("wrong argument size %d; expected $...-%d", size, fn.size) + badf("wrong argument size %d; expected $...-%d", size, fn.size) } } continue @@ -165,7 +165,7 @@ func asmCheck(pkg *Package) { } for _, m := range asmUnnamedFP.FindAllStringSubmatch(line, -1) { - warnf("use of unnamed argument %s", m[1]) + badf("use of unnamed argument %s", m[1]) } for _, m := range asmNamedFP.FindAllStringSubmatch(line, -1) { @@ -182,13 +182,13 @@ func asmCheck(pkg *Package) { } v = fn.varByOffset[off] if v != nil { - warnf("unknown variable %s; offset %d is %s+%d(FP)", name, off, v.name, v.off) + badf("unknown variable %s; offset %d is %s+%d(FP)", name, off, v.name, v.off) } else { - warnf("unknown variable %s", name) + badf("unknown variable %s", name) } continue } - asmCheckVar(warnf, fn, line, m[0], off, v) + asmCheckVar(badf, fn, line, m[0], off, v) } } } @@ -417,10 +417,10 @@ func (f *File) asmParseDecl(decl *ast.FuncDecl) map[string]*asmFunc { } // asmCheckVar checks a single variable reference. -func asmCheckVar(warnf func(string, ...interface{}), fn *asmFunc, line, expr string, off int, v *asmVar) { +func asmCheckVar(badf func(string, ...interface{}), fn *asmFunc, line, expr string, off int, v *asmVar) { m := asmOpcode.FindStringSubmatch(line) if m == nil { - warnf("cannot find assembly opcode") + badf("cannot find assembly opcode") } // Determine operand sizes from instruction. @@ -510,7 +510,7 @@ func asmCheckVar(warnf func(string, ...interface{}), fn *asmFunc, line, expr str } fmt.Fprintf(&inner, "%s+%d(FP)", vi.name, vi.off) } - warnf("invalid offset %s; expected %s+%d(FP)%s", expr, v.name, v.off, inner.String()) + badf("invalid offset %s; expected %s+%d(FP)%s", expr, v.name, v.off, inner.String()) return } if kind != 0 && kind != vk { @@ -528,6 +528,6 @@ func asmCheckVar(warnf func(string, ...interface{}), fn *asmFunc, line, expr str fmt.Fprintf(&inner, "%s+%d(FP)", vi.name, vi.off) } } - warnf("invalid %s of %s; %s is %d-byte value%s", op, expr, vt, vk, inner.String()) + badf("invalid %s of %s; %s is %d-byte value%s", op, expr, vt, vk, inner.String()) } } diff --git a/cmd/vet/assign.go b/cmd/vet/assign.go index a11f0f87..58123a7d 100644 --- a/cmd/vet/assign.go +++ b/cmd/vet/assign.go @@ -38,7 +38,7 @@ func (f *File) checkAssignStmt(stmt *ast.AssignStmt) { le := f.gofmt(lhs) re := f.gofmt(rhs) if le == re { - f.Warnf(stmt.Pos(), "self-assignment of %s to %s", re, le) + f.Badf(stmt.Pos(), "self-assignment of %s to %s", re, le) } } } diff --git a/cmd/vet/atomic.go b/cmd/vet/atomic.go index 4ab256f6..dfe3f03c 100644 --- a/cmd/vet/atomic.go +++ b/cmd/vet/atomic.go @@ -54,6 +54,6 @@ func (f *File) checkAtomicAddAssignment(left ast.Expr, call *ast.CallExpr) { } if broken { - f.Warn(left.Pos(), "direct assignment to atomic value") + f.Bad(left.Pos(), "direct assignment to atomic value") } } diff --git a/cmd/vet/composite.go b/cmd/vet/composite.go index 1168d26b..879e6ce6 100644 --- a/cmd/vet/composite.go +++ b/cmd/vet/composite.go @@ -94,7 +94,7 @@ func (f *File) checkUnkeyedLiteral(c *ast.CompositeLit) { return } - f.Warn(c.Pos(), typeString+" composite literal uses unkeyed fields") + f.Bad(c.Pos(), typeString+" composite literal uses unkeyed fields") } // pkgPath returns the import path "image/png" for the package name "png". diff --git a/cmd/vet/copylock.go b/cmd/vet/copylock.go index d5c20e08..31651eff 100644 --- a/cmd/vet/copylock.go +++ b/cmd/vet/copylock.go @@ -26,7 +26,7 @@ func (f *File) checkCopyLocks(d *ast.FuncDecl) { if d.Recv != nil && len(d.Recv.List) > 0 { expr := d.Recv.List[0].Type if path := lockPath(f.pkg.typesPkg, f.pkg.types[expr].Type); path != nil { - f.Warnf(expr.Pos(), "%s passes Lock by value: %v", d.Name.Name, path) + f.Badf(expr.Pos(), "%s passes Lock by value: %v", d.Name.Name, path) } } @@ -34,7 +34,7 @@ func (f *File) checkCopyLocks(d *ast.FuncDecl) { for _, field := range d.Type.Params.List { expr := field.Type if path := lockPath(f.pkg.typesPkg, f.pkg.types[expr].Type); path != nil { - f.Warnf(expr.Pos(), "%s passes Lock by value: %v", d.Name.Name, path) + f.Badf(expr.Pos(), "%s passes Lock by value: %v", d.Name.Name, path) } } } @@ -43,7 +43,7 @@ func (f *File) checkCopyLocks(d *ast.FuncDecl) { for _, field := range d.Type.Results.List { expr := field.Type if path := lockPath(f.pkg.typesPkg, f.pkg.types[expr].Type); path != nil { - f.Warnf(expr.Pos(), "%s returns Lock by value: %v", d.Name.Name, path) + f.Badf(expr.Pos(), "%s returns Lock by value: %v", d.Name.Name, path) } } } diff --git a/cmd/vet/deadcode.go b/cmd/vet/deadcode.go index f90fc14a..a956930c 100644 --- a/cmd/vet/deadcode.go +++ b/cmd/vet/deadcode.go @@ -155,7 +155,7 @@ func (d *deadState) findDead(stmt ast.Stmt) { case *ast.EmptyStmt: // do not warn about unreachable empty statements default: - d.f.Warnf(stmt.Pos(), "unreachable code") + d.f.Bad(stmt.Pos(), "unreachable code") d.reachable = true // silence error about next statement } } diff --git a/cmd/vet/print.go b/cmd/vet/print.go index ab96dcf6..b47dbd02 100644 --- a/cmd/vet/print.go +++ b/cmd/vet/print.go @@ -82,7 +82,7 @@ type formatState struct { // call.Args[formatIndex] is (well, should be) the format argument. func (f *File) checkPrintf(call *ast.CallExpr, name string, formatIndex int) { if formatIndex >= len(call.Args) { - f.Warn(call.Pos(), "too few arguments in call to", name) + f.Bad(call.Pos(), "too few arguments in call to", name) return } lit := f.pkg.types[call.Args[formatIndex]].Value diff --git a/cmd/vet/rangeloop.go b/cmd/vet/rangeloop.go index ecc59542..61fd6ac5 100644 --- a/cmd/vet/rangeloop.go +++ b/cmd/vet/rangeloop.go @@ -58,7 +58,7 @@ func checkRangeLoop(f *File, n *ast.RangeStmt) { return true } if key != nil && id.Obj == key.Obj || val != nil && id.Obj == val.Obj { - f.Warn(id.Pos(), "range variable", id.Name, "enclosed by function") + f.Bad(id.Pos(), "range variable", id.Name, "enclosed by function") } return true })