Commit 5d39af9d authored by Daniel Martí's avatar Daniel Martí

all: remove some unused result params

Most of these are return values that were part of a receiving parameter,
so they're still accessible.

A few others are not, but those have never had a use.

Found with github.com/mvdan/unparam, after Kevin Burke's suggestion that
the tool should also warn about unused result parameters.

Change-Id: Id8b5ed89912a99db22027703a88bd94d0b292b8b
Reviewed-on: https://go-review.googlesource.com/55910
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 0c4d035c
...@@ -258,11 +258,11 @@ func (p *Parser) parseScale(s string) int8 { ...@@ -258,11 +258,11 @@ func (p *Parser) parseScale(s string) int8 {
} }
// operand parses a general operand and stores the result in *a. // operand parses a general operand and stores the result in *a.
func (p *Parser) operand(a *obj.Addr) bool { func (p *Parser) operand(a *obj.Addr) {
//fmt.Printf("Operand: %v\n", p.input) //fmt.Printf("Operand: %v\n", p.input)
if len(p.input) == 0 { if len(p.input) == 0 {
p.errorf("empty operand: cannot happen") p.errorf("empty operand: cannot happen")
return false return
} }
// General address (with a few exceptions) looks like // General address (with a few exceptions) looks like
// $sym±offset(SB)(reg)(index*scale) // $sym±offset(SB)(reg)(index*scale)
...@@ -290,7 +290,7 @@ func (p *Parser) operand(a *obj.Addr) bool { ...@@ -290,7 +290,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
p.symbolReference(a, name, prefix) p.symbolReference(a, name, prefix)
// fmt.Printf("SYM %s\n", obj.Dconv(&emptyProg, 0, a)) // fmt.Printf("SYM %s\n", obj.Dconv(&emptyProg, 0, a))
if p.peek() == scanner.EOF { if p.peek() == scanner.EOF {
return true return
} }
} }
...@@ -301,7 +301,7 @@ func (p *Parser) operand(a *obj.Addr) bool { ...@@ -301,7 +301,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
} }
p.registerList(a) p.registerList(a)
p.expectOperandEnd() p.expectOperandEnd()
return true return
} }
// Register: R1 // Register: R1
...@@ -335,7 +335,7 @@ func (p *Parser) operand(a *obj.Addr) bool { ...@@ -335,7 +335,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
} }
// fmt.Printf("REG %s\n", obj.Dconv(&emptyProg, 0, a)) // fmt.Printf("REG %s\n", obj.Dconv(&emptyProg, 0, a))
p.expectOperandEnd() p.expectOperandEnd()
return true return
} }
// Constant. // Constant.
...@@ -348,7 +348,7 @@ func (p *Parser) operand(a *obj.Addr) bool { ...@@ -348,7 +348,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
tok := p.next() tok := p.next()
if tok.ScanToken == scanner.EOF { if tok.ScanToken == scanner.EOF {
p.errorf("missing right parenthesis") p.errorf("missing right parenthesis")
return false return
} }
rname := tok.String() rname := tok.String()
p.back() p.back()
...@@ -367,12 +367,12 @@ func (p *Parser) operand(a *obj.Addr) bool { ...@@ -367,12 +367,12 @@ func (p *Parser) operand(a *obj.Addr) bool {
a.Val = p.floatExpr() a.Val = p.floatExpr()
// fmt.Printf("FCONST %s\n", obj.Dconv(&emptyProg, 0, a)) // fmt.Printf("FCONST %s\n", obj.Dconv(&emptyProg, 0, a))
p.expectOperandEnd() p.expectOperandEnd()
return true return
} }
if p.have(scanner.String) { if p.have(scanner.String) {
if prefix != '$' { if prefix != '$' {
p.errorf("string constant must be an immediate") p.errorf("string constant must be an immediate")
return false return
} }
str, err := strconv.Unquote(p.get(scanner.String).String()) str, err := strconv.Unquote(p.get(scanner.String).String())
if err != nil { if err != nil {
...@@ -382,7 +382,7 @@ func (p *Parser) operand(a *obj.Addr) bool { ...@@ -382,7 +382,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
a.Val = str a.Val = str
// fmt.Printf("SCONST %s\n", obj.Dconv(&emptyProg, 0, a)) // fmt.Printf("SCONST %s\n", obj.Dconv(&emptyProg, 0, a))
p.expectOperandEnd() p.expectOperandEnd()
return true return
} }
a.Offset = int64(p.expr()) a.Offset = int64(p.expr())
if p.peek() != '(' { if p.peek() != '(' {
...@@ -396,7 +396,7 @@ func (p *Parser) operand(a *obj.Addr) bool { ...@@ -396,7 +396,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
} }
// fmt.Printf("CONST %d %s\n", a.Offset, obj.Dconv(&emptyProg, 0, a)) // fmt.Printf("CONST %d %s\n", a.Offset, obj.Dconv(&emptyProg, 0, a))
p.expectOperandEnd() p.expectOperandEnd()
return true return
} }
// fmt.Printf("offset %d \n", a.Offset) // fmt.Printf("offset %d \n", a.Offset)
} }
...@@ -406,7 +406,7 @@ func (p *Parser) operand(a *obj.Addr) bool { ...@@ -406,7 +406,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
// fmt.Printf("DONE %s\n", p.arch.Dconv(&emptyProg, 0, a)) // fmt.Printf("DONE %s\n", p.arch.Dconv(&emptyProg, 0, a))
p.expectOperandEnd() p.expectOperandEnd()
return true return
} }
// atStartOfRegister reports whether the parser is at the start of a register definition. // atStartOfRegister reports whether the parser is at the start of a register definition.
......
...@@ -742,7 +742,7 @@ func tointerface(l []*Node) *types.Type { ...@@ -742,7 +742,7 @@ func tointerface(l []*Node) *types.Type {
return t return t
} }
func tointerface0(t *types.Type, l []*Node) *types.Type { func tointerface0(t *types.Type, l []*Node) {
if t == nil || !t.IsInterface() { if t == nil || !t.IsInterface() {
Fatalf("interface expected") Fatalf("interface expected")
} }
...@@ -756,8 +756,6 @@ func tointerface0(t *types.Type, l []*Node) *types.Type { ...@@ -756,8 +756,6 @@ func tointerface0(t *types.Type, l []*Node) *types.Type {
fields = append(fields, f) fields = append(fields, f)
} }
t.SetInterface(fields) t.SetInterface(fields)
return t
} }
func fakeRecv() *Node { func fakeRecv() *Node {
......
...@@ -3671,7 +3671,7 @@ ret: ...@@ -3671,7 +3671,7 @@ ret:
ntypecheckdeftype-- ntypecheckdeftype--
} }
func typecheckdef(n *Node) *Node { func typecheckdef(n *Node) {
lno := lineno lno := lineno
setlineno(n) setlineno(n)
...@@ -3687,11 +3687,11 @@ func typecheckdef(n *Node) *Node { ...@@ -3687,11 +3687,11 @@ func typecheckdef(n *Node) *Node {
yyerror("undefined: %v", n.Sym) yyerror("undefined: %v", n.Sym)
} }
return n return
} }
if n.Walkdef() == 1 { if n.Walkdef() == 1 {
return n return
} }
typecheckdefstack = append(typecheckdefstack, n) typecheckdefstack = append(typecheckdefstack, n)
...@@ -3857,7 +3857,7 @@ ret: ...@@ -3857,7 +3857,7 @@ ret:
lineno = lno lineno = lno
n.SetWalkdef(1) n.SetWalkdef(1)
return n return
} }
func checkmake(t *types.Type, arg string, n *Node) bool { func checkmake(t *types.Type, arg string, n *Node) bool {
......
...@@ -121,9 +121,8 @@ func trimmableBlock(b *Block) bool { ...@@ -121,9 +121,8 @@ func trimmableBlock(b *Block) bool {
} }
// mergePhi adjusts the number of `v`s arguments to account for merge // mergePhi adjusts the number of `v`s arguments to account for merge
// of `b`, which was `i`th predecessor of the `v`s block. Returns // of `b`, which was `i`th predecessor of the `v`s block.
// `v`. func mergePhi(v *Value, i int, b *Block) {
func mergePhi(v *Value, i int, b *Block) *Value {
u := v.Args[i] u := v.Args[i]
if u.Block == b { if u.Block == b {
if u.Op != OpPhi { if u.Op != OpPhi {
...@@ -147,5 +146,4 @@ func mergePhi(v *Value, i int, b *Block) *Value { ...@@ -147,5 +146,4 @@ func mergePhi(v *Value, i int, b *Block) *Value {
v.AddArg(v.Args[i]) v.AddArg(v.Args[i])
} }
} }
return v
} }
...@@ -857,7 +857,7 @@ var foldPath = make(map[string]string) ...@@ -857,7 +857,7 @@ var foldPath = make(map[string]string)
// load populates p using information from bp, err, which should // load populates p using information from bp, err, which should
// be the result of calling build.Context.Import. // be the result of calling build.Context.Import.
func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package { func (p *Package) load(stk *ImportStack, bp *build.Package, err error) {
p.copyBuild(bp) p.copyBuild(bp)
// The localPrefix is the path we interpret ./ imports relative to. // The localPrefix is the path we interpret ./ imports relative to.
...@@ -874,7 +874,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package ...@@ -874,7 +874,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
ImportStack: stk.Copy(), ImportStack: stk.Copy(),
Err: err.Error(), Err: err.Error(),
} }
return p return
} }
useBindir := p.Name == "main" useBindir := p.Name == "main"
...@@ -891,7 +891,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package ...@@ -891,7 +891,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
newPath := strings.Replace(p.ImportPath, "code.google.com/p/go.", "golang.org/x/", 1) newPath := strings.Replace(p.ImportPath, "code.google.com/p/go.", "golang.org/x/", 1)
e := fmt.Sprintf("the %v command has moved; use %v instead.", p.ImportPath, newPath) e := fmt.Sprintf("the %v command has moved; use %v instead.", p.ImportPath, newPath)
p.Error = &PackageError{Err: e} p.Error = &PackageError{Err: e}
return p return
} }
_, elem := filepath.Split(p.Dir) _, elem := filepath.Split(p.Dir)
full := cfg.BuildContext.GOOS + "_" + cfg.BuildContext.GOARCH + "/" + elem full := cfg.BuildContext.GOOS + "_" + cfg.BuildContext.GOARCH + "/" + elem
...@@ -1046,7 +1046,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package ...@@ -1046,7 +1046,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
ImportStack: stk.Copy(), ImportStack: stk.Copy(),
Err: fmt.Sprintf("case-insensitive file name collision: %q and %q", f1, f2), Err: fmt.Sprintf("case-insensitive file name collision: %q and %q", f1, f2),
} }
return p return
} }
// Build list of imported packages and full dependency list. // Build list of imported packages and full dependency list.
...@@ -1141,7 +1141,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package ...@@ -1141,7 +1141,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
ImportStack: stk.Copy(), ImportStack: stk.Copy(),
Err: fmt.Sprintf("C source files not allowed when not using cgo or SWIG: %s", strings.Join(p.CFiles, " ")), Err: fmt.Sprintf("C source files not allowed when not using cgo or SWIG: %s", strings.Join(p.CFiles, " ")),
} }
return p return
} }
// Check for case-insensitive collisions of import paths. // Check for case-insensitive collisions of import paths.
...@@ -1153,7 +1153,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package ...@@ -1153,7 +1153,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
ImportStack: stk.Copy(), ImportStack: stk.Copy(),
Err: fmt.Sprintf("case-insensitive import collision: %q and %q", p.ImportPath, other), Err: fmt.Sprintf("case-insensitive import collision: %q and %q", p.ImportPath, other),
} }
return p return
} }
if p.BinaryOnly { if p.BinaryOnly {
...@@ -1165,7 +1165,6 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package ...@@ -1165,7 +1165,6 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
} else { } else {
computeBuildID(p) computeBuildID(p)
} }
return p
} }
// InternalDeps returns the full dependency list for p, // InternalDeps returns the full dependency list for p,
......
...@@ -871,8 +871,7 @@ func (w *reflectWithString) resolve() error { ...@@ -871,8 +871,7 @@ func (w *reflectWithString) resolve() error {
} }
// NOTE: keep in sync with stringBytes below. // NOTE: keep in sync with stringBytes below.
func (e *encodeState) string(s string, escapeHTML bool) int { func (e *encodeState) string(s string, escapeHTML bool) {
len0 := e.Len()
e.WriteByte('"') e.WriteByte('"')
start := 0 start := 0
for i := 0; i < len(s); { for i := 0; i < len(s); {
...@@ -944,12 +943,10 @@ func (e *encodeState) string(s string, escapeHTML bool) int { ...@@ -944,12 +943,10 @@ func (e *encodeState) string(s string, escapeHTML bool) int {
e.WriteString(s[start:]) e.WriteString(s[start:])
} }
e.WriteByte('"') e.WriteByte('"')
return e.Len() - len0
} }
// NOTE: keep in sync with string above. // NOTE: keep in sync with string above.
func (e *encodeState) stringBytes(s []byte, escapeHTML bool) int { func (e *encodeState) stringBytes(s []byte, escapeHTML bool) {
len0 := e.Len()
e.WriteByte('"') e.WriteByte('"')
start := 0 start := 0
for i := 0; i < len(s); { for i := 0; i < len(s); {
...@@ -1021,7 +1018,6 @@ func (e *encodeState) stringBytes(s []byte, escapeHTML bool) int { ...@@ -1021,7 +1018,6 @@ func (e *encodeState) stringBytes(s []byte, escapeHTML bool) int {
e.Write(s[start:]) e.Write(s[start:])
} }
e.WriteByte('"') e.WriteByte('"')
return e.Len() - len0
} }
// A field represents a single field found in a struct. // A field represents a single field found in a struct.
......
...@@ -238,7 +238,7 @@ var labelsOnce sync.Once ...@@ -238,7 +238,7 @@ var labelsOnce sync.Once
// run executes the benchmark in a separate goroutine, including all of its // run executes the benchmark in a separate goroutine, including all of its
// subbenchmarks. b must not have subbenchmarks. // subbenchmarks. b must not have subbenchmarks.
func (b *B) run() BenchmarkResult { func (b *B) run() {
labelsOnce.Do(func() { labelsOnce.Do(func() {
fmt.Fprintf(b.w, "goos: %s\n", runtime.GOOS) fmt.Fprintf(b.w, "goos: %s\n", runtime.GOOS)
fmt.Fprintf(b.w, "goarch: %s\n", runtime.GOARCH) fmt.Fprintf(b.w, "goarch: %s\n", runtime.GOARCH)
...@@ -253,7 +253,6 @@ func (b *B) run() BenchmarkResult { ...@@ -253,7 +253,6 @@ func (b *B) run() BenchmarkResult {
// Running func Benchmark. // Running func Benchmark.
b.doBench() b.doBench()
} }
return b.result
} }
func (b *B) doBench() BenchmarkResult { func (b *B) doBench() BenchmarkResult {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment