1
0
mirror of https://github.com/golang/go synced 2024-11-19 14:34:42 -07:00

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: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Daniel Martí 2017-08-15 21:15:26 +01:00
parent 0c4d035ca8
commit 5d39af9d9b
7 changed files with 27 additions and 37 deletions

View 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.

View 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 {

View 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 {

View 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
}

View 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,

View 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.

View 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 {