]> Cypherpunks repositories - gostls13.git/commitdiff
all: remove some unused result params
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 15 Aug 2017 20:15:26 +0000 (21:15 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 28 Aug 2017 06:52:55 +0000 (06:52 +0000)
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: Ian Lance Taylor <iant@golang.org>
src/cmd/asm/internal/asm/parse.go
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/ssa/trim.go
src/cmd/go/internal/load/pkg.go
src/encoding/json/encode.go
src/testing/benchmark.go

index a6e13db74961767dd841cfb4de26fbfcfcfbcce0..c0dd2db341a49e081553de186da7a597d10dc6be 100644 (file)
@@ -258,11 +258,11 @@ func (p *Parser) parseScale(s string) int8 {
 }
 
 // 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)
        if len(p.input) == 0 {
                p.errorf("empty operand: cannot happen")
-               return false
+               return
        }
        // General address (with a few exceptions) looks like
        //      $sym±offset(SB)(reg)(index*scale)
@@ -290,7 +290,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
                p.symbolReference(a, name, prefix)
                // fmt.Printf("SYM %s\n", obj.Dconv(&emptyProg, 0, a))
                if p.peek() == scanner.EOF {
-                       return true
+                       return
                }
        }
 
@@ -301,7 +301,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
                }
                p.registerList(a)
                p.expectOperandEnd()
-               return true
+               return
        }
 
        // Register: R1
@@ -335,7 +335,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
                }
                // fmt.Printf("REG %s\n", obj.Dconv(&emptyProg, 0, a))
                p.expectOperandEnd()
-               return true
+               return
        }
 
        // Constant.
@@ -348,7 +348,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
                tok := p.next()
                if tok.ScanToken == scanner.EOF {
                        p.errorf("missing right parenthesis")
-                       return false
+                       return
                }
                rname := tok.String()
                p.back()
@@ -367,12 +367,12 @@ func (p *Parser) operand(a *obj.Addr) bool {
                        a.Val = p.floatExpr()
                        // fmt.Printf("FCONST %s\n", obj.Dconv(&emptyProg, 0, a))
                        p.expectOperandEnd()
-                       return true
+                       return
                }
                if p.have(scanner.String) {
                        if prefix != '$' {
                                p.errorf("string constant must be an immediate")
-                               return false
+                               return
                        }
                        str, err := strconv.Unquote(p.get(scanner.String).String())
                        if err != nil {
@@ -382,7 +382,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
                        a.Val = str
                        // fmt.Printf("SCONST %s\n", obj.Dconv(&emptyProg, 0, a))
                        p.expectOperandEnd()
-                       return true
+                       return
                }
                a.Offset = int64(p.expr())
                if p.peek() != '(' {
@@ -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))
                        p.expectOperandEnd()
-                       return true
+                       return
                }
                // fmt.Printf("offset %d \n", a.Offset)
        }
@@ -406,7 +406,7 @@ func (p *Parser) operand(a *obj.Addr) bool {
        // fmt.Printf("DONE %s\n", p.arch.Dconv(&emptyProg, 0, a))
 
        p.expectOperandEnd()
-       return true
+       return
 }
 
 // atStartOfRegister reports whether the parser is at the start of a register definition.
index 6052cd438f65ad9ca026829e6288ae0dd60894a2..3da38e7edd518a4a648066882861fa3a9a25fd5e 100644 (file)
@@ -742,7 +742,7 @@ func tointerface(l []*Node) *types.Type {
        return t
 }
 
-func tointerface0(t *types.Type, l []*Node) *types.Type {
+func tointerface0(t *types.Type, l []*Node) {
        if t == nil || !t.IsInterface() {
                Fatalf("interface expected")
        }
@@ -756,8 +756,6 @@ func tointerface0(t *types.Type, l []*Node) *types.Type {
                fields = append(fields, f)
        }
        t.SetInterface(fields)
-
-       return t
 }
 
 func fakeRecv() *Node {
index 2f30581cb861ba17211144ba9a63c7ec9baa9814..0bef396da237538f4a57180058ba23e4849db223 100644 (file)
@@ -3671,7 +3671,7 @@ ret:
        ntypecheckdeftype--
 }
 
-func typecheckdef(n *Node) *Node {
+func typecheckdef(n *Node) {
        lno := lineno
        setlineno(n)
 
@@ -3687,11 +3687,11 @@ func typecheckdef(n *Node) *Node {
                        yyerror("undefined: %v", n.Sym)
                }
 
-               return n
+               return
        }
 
        if n.Walkdef() == 1 {
-               return n
+               return
        }
 
        typecheckdefstack = append(typecheckdefstack, n)
@@ -3857,7 +3857,7 @@ ret:
 
        lineno = lno
        n.SetWalkdef(1)
-       return n
+       return
 }
 
 func checkmake(t *types.Type, arg string, n *Node) bool {
index 04b4fd4d54196a97ad5b4dd6cafd9263ec7d5b7d..d97c6baaa1bff73c6b55f97aa03fcb0f9c5f67e4 100644 (file)
@@ -121,9 +121,8 @@ func trimmableBlock(b *Block) bool {
 }
 
 // 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
-// `v`.
-func mergePhi(v *Value, i int, b *Block) *Value {
+// of `b`, which was `i`th predecessor of the `v`s block.
+func mergePhi(v *Value, i int, b *Block) {
        u := v.Args[i]
        if u.Block == b {
                if u.Op != OpPhi {
@@ -147,5 +146,4 @@ func mergePhi(v *Value, i int, b *Block) *Value {
                        v.AddArg(v.Args[i])
                }
        }
-       return v
 }
index ae2151561a03b6fa2b8ebe9dfb296571a34dea22..be31ef5615ad67ec29862afa3e3f2fc9dfd0e61a 100644 (file)
@@ -857,7 +857,7 @@ var foldPath = make(map[string]string)
 
 // load populates p using information from bp, err, which should
 // 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)
 
        // 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
                        ImportStack: stk.Copy(),
                        Err:         err.Error(),
                }
-               return p
+               return
        }
 
        useBindir := p.Name == "main"
@@ -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)
                        e := fmt.Sprintf("the %v command has moved; use %v instead.", p.ImportPath, newPath)
                        p.Error = &PackageError{Err: e}
-                       return p
+                       return
                }
                _, elem := filepath.Split(p.Dir)
                full := cfg.BuildContext.GOOS + "_" + cfg.BuildContext.GOARCH + "/" + elem
@@ -1046,7 +1046,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
                        ImportStack: stk.Copy(),
                        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.
@@ -1141,7 +1141,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
                        ImportStack: stk.Copy(),
                        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.
@@ -1153,7 +1153,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
                        ImportStack: stk.Copy(),
                        Err:         fmt.Sprintf("case-insensitive import collision: %q and %q", p.ImportPath, other),
                }
-               return p
+               return
        }
 
        if p.BinaryOnly {
@@ -1165,7 +1165,6 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
        } else {
                computeBuildID(p)
        }
-       return p
 }
 
 // InternalDeps returns the full dependency list for p,
index 0371f0a24dd3543f79402bc066fc3fae7779eeda..141b23c6c63f5b9b7ff320adc1118caafd7ce966 100644 (file)
@@ -871,8 +871,7 @@ func (w *reflectWithString) resolve() error {
 }
 
 // NOTE: keep in sync with stringBytes below.
-func (e *encodeState) string(s string, escapeHTML bool) int {
-       len0 := e.Len()
+func (e *encodeState) string(s string, escapeHTML bool) {
        e.WriteByte('"')
        start := 0
        for i := 0; i < len(s); {
@@ -944,12 +943,10 @@ func (e *encodeState) string(s string, escapeHTML bool) int {
                e.WriteString(s[start:])
        }
        e.WriteByte('"')
-       return e.Len() - len0
 }
 
 // NOTE: keep in sync with string above.
-func (e *encodeState) stringBytes(s []byte, escapeHTML bool) int {
-       len0 := e.Len()
+func (e *encodeState) stringBytes(s []byte, escapeHTML bool) {
        e.WriteByte('"')
        start := 0
        for i := 0; i < len(s); {
@@ -1021,7 +1018,6 @@ func (e *encodeState) stringBytes(s []byte, escapeHTML bool) int {
                e.Write(s[start:])
        }
        e.WriteByte('"')
-       return e.Len() - len0
 }
 
 // A field represents a single field found in a struct.
index 0a08cca7b394a0daa38a52c03c396098d652937f..d592afbf87da3253fd3789900791a6d625cc7360 100644 (file)
@@ -238,7 +238,7 @@ var labelsOnce sync.Once
 
 // run executes the benchmark in a separate goroutine, including all of its
 // subbenchmarks. b must not have subbenchmarks.
-func (b *B) run() BenchmarkResult {
+func (b *B) run() {
        labelsOnce.Do(func() {
                fmt.Fprintf(b.w, "goos: %s\n", runtime.GOOS)
                fmt.Fprintf(b.w, "goarch: %s\n", runtime.GOARCH)
@@ -253,7 +253,6 @@ func (b *B) run() BenchmarkResult {
                // Running func Benchmark.
                b.doBench()
        }
-       return b.result
 }
 
 func (b *B) doBench() BenchmarkResult {