Skip to content

Commit

Permalink
cmd/go: remove some unused parameters
Browse files Browse the repository at this point in the history
Change-Id: I441b3045e76afc1c561914926c14efc8a116c8a7
Reviewed-on: https://go-review.googlesource.com/101195
Run-TryBot: Daniel Martí <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
mvdan committed Mar 16, 2018
1 parent b30bf95 commit 2767c4e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/cmd/go/internal/work/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TestRespectSetgidDir(t *testing.T) {
defer pkgfile.Close()

dirGIDFile := filepath.Join(setgiddir, "setgid")
if err := b.moveOrCopyFile(nil, dirGIDFile, pkgfile.Name(), 0666, true); err != nil {
if err := b.moveOrCopyFile(dirGIDFile, pkgfile.Name(), 0666, true); err != nil {
t.Fatalf("moveOrCopyFile: %v", err)
}

Expand Down
40 changes: 20 additions & 20 deletions src/cmd/go/internal/work/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ func (b *Builder) build(a *Action) (err error) {
// Not covering this file.
continue
}
if err := b.cover(a, coverFile, sourceFile, 0666, cover.Var); err != nil {
if err := b.cover(a, coverFile, sourceFile, cover.Var); err != nil {
return err
}
if i < len(gofiles) {
Expand Down Expand Up @@ -596,17 +596,17 @@ func (b *Builder) build(a *Action) (err error) {
switch {
case strings.HasSuffix(name, _goos_goarch):
targ := file[:len(name)-len(_goos_goarch)] + "_GOOS_GOARCH." + ext
if err := b.copyFile(a, objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil {
if err := b.copyFile(objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil {
return err
}
case strings.HasSuffix(name, _goarch):
targ := file[:len(name)-len(_goarch)] + "_GOARCH." + ext
if err := b.copyFile(a, objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil {
if err := b.copyFile(objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil {
return err
}
case strings.HasSuffix(name, _goos):
targ := file[:len(name)-len(_goos)] + "_GOOS." + ext
if err := b.copyFile(a, objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil {
if err := b.copyFile(objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil {
return err
}
}
Expand Down Expand Up @@ -954,7 +954,7 @@ func (b *Builder) getPkgConfigFlags(p *load.Package) (cflags, ldflags []string,
}
}
var out []byte
out, err = b.runOut(p.Dir, p.ImportPath, nil, b.PkgconfigCmd(), "--cflags", pcflags, "--", pkgs)
out, err = b.runOut(p.Dir, nil, b.PkgconfigCmd(), "--cflags", pcflags, "--", pkgs)
if err != nil {
b.showOutput(nil, p.Dir, b.PkgconfigCmd()+" --cflags "+strings.Join(pcflags, " ")+strings.Join(pkgs, " "), string(out))
b.Print(err.Error() + "\n")
Expand All @@ -966,7 +966,7 @@ func (b *Builder) getPkgConfigFlags(p *load.Package) (cflags, ldflags []string,
return nil, nil, err
}
}
out, err = b.runOut(p.Dir, p.ImportPath, nil, b.PkgconfigCmd(), "--libs", pcflags, "--", pkgs)
out, err = b.runOut(p.Dir, nil, b.PkgconfigCmd(), "--libs", pcflags, "--", pkgs)
if err != nil {
b.showOutput(nil, p.Dir, b.PkgconfigCmd()+" --libs "+strings.Join(pcflags, " ")+strings.Join(pkgs, " "), string(out))
b.Print(err.Error() + "\n")
Expand Down Expand Up @@ -1126,7 +1126,7 @@ func BuildInstallFunc(b *Builder, a *Action) (err error) {

defer b.cleanup(a1)

return b.moveOrCopyFile(a, a.Target, a1.built, perm, false)
return b.moveOrCopyFile(a.Target, a1.built, perm, false)
}

// cleanup removes a's object dir to keep the amount of
Expand All @@ -1143,7 +1143,7 @@ func (b *Builder) cleanup(a *Action) {
}

// moveOrCopyFile is like 'mv src dst' or 'cp src dst'.
func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, force bool) error {
func (b *Builder) moveOrCopyFile(dst, src string, perm os.FileMode, force bool) error {
if cfg.BuildN {
b.Showcmd("", "mv %s %s", src, dst)
return nil
Expand All @@ -1154,23 +1154,23 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f

// If the source is in the build cache, we need to copy it.
if strings.HasPrefix(src, cache.DefaultDir()) {
return b.copyFile(a, dst, src, perm, force)
return b.copyFile(dst, src, perm, force)
}

// On Windows, always copy the file, so that we respect the NTFS
// permissions of the parent folder. https://golang.org/issue/22343.
// What matters here is not cfg.Goos (the system we are building
// for) but runtime.GOOS (the system we are building on).
if runtime.GOOS == "windows" {
return b.copyFile(a, dst, src, perm, force)
return b.copyFile(dst, src, perm, force)
}

// If the destination directory has the group sticky bit set,
// we have to copy the file to retain the correct permissions.
// https://golang.org/issue/18878
if fi, err := os.Stat(filepath.Dir(dst)); err == nil {
if fi.IsDir() && (fi.Mode()&os.ModeSetgid) != 0 {
return b.copyFile(a, dst, src, perm, force)
return b.copyFile(dst, src, perm, force)
}
}

Expand Down Expand Up @@ -1200,11 +1200,11 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f
}
}

return b.copyFile(a, dst, src, perm, force)
return b.copyFile(dst, src, perm, force)
}

// copyFile is like 'cp src dst'.
func (b *Builder) copyFile(a *Action, dst, src string, perm os.FileMode, force bool) error {
func (b *Builder) copyFile(dst, src string, perm os.FileMode, force bool) error {
if cfg.BuildN || cfg.BuildX {
b.Showcmd("", "cp %s %s", src, dst)
if cfg.BuildN {
Expand Down Expand Up @@ -1295,12 +1295,12 @@ func (b *Builder) installHeader(a *Action) error {
}
}

return b.moveOrCopyFile(a, a.Target, src, 0666, true)
return b.moveOrCopyFile(a.Target, src, 0666, true)
}

// cover runs, in effect,
// go tool cover -mode=b.coverMode -var="varName" -o dst.go src.go
func (b *Builder) cover(a *Action, dst, src string, perm os.FileMode, varName string) error {
func (b *Builder) cover(a *Action, dst, src string, varName string) error {
return b.run(a, a.Objdir, "cover "+a.Package.ImportPath, nil,
cfg.BuildToolexec,
base.Tool("cover"),
Expand Down Expand Up @@ -1447,7 +1447,7 @@ var cgoTypeSigRe = regexp.MustCompile(`\b_C2?(type|func|var|macro)_\B`)
// If the command fails, run prints information about the failure
// and returns a non-nil error.
func (b *Builder) run(a *Action, dir string, desc string, env []string, cmdargs ...interface{}) error {
out, err := b.runOut(dir, desc, env, cmdargs...)
out, err := b.runOut(dir, env, cmdargs...)
if len(out) > 0 {
if desc == "" {
desc = b.fmtcmd(dir, "%s", strings.Join(str.StringList(cmdargs...), " "))
Expand Down Expand Up @@ -1479,7 +1479,7 @@ func (b *Builder) processOutput(out []byte) string {

// runOut runs the command given by cmdline in the directory dir.
// It returns the command output and any errors that occurred.
func (b *Builder) runOut(dir string, desc string, env []string, cmdargs ...interface{}) ([]byte, error) {
func (b *Builder) runOut(dir string, env []string, cmdargs ...interface{}) ([]byte, error) {
cmdline := str.StringList(cmdargs...)

for _, arg := range cmdline {
Expand Down Expand Up @@ -1691,7 +1691,7 @@ func (b *Builder) ccompile(a *Action, p *load.Package, outfile string, flags []s
if !filepath.IsAbs(outfile) {
outfile = filepath.Join(p.Dir, outfile)
}
output, err := b.runOut(filepath.Dir(file), desc, nil, compiler, flags, "-o", outfile, "-c", filepath.Base(file))
output, err := b.runOut(filepath.Dir(file), nil, compiler, flags, "-o", outfile, "-c", filepath.Base(file))
if len(output) > 0 {
// On FreeBSD 11, when we pass -g to clang 3.8 it
// invokes its internal assembler with -dwarf-version=2.
Expand Down Expand Up @@ -2215,7 +2215,7 @@ var (
)

func (b *Builder) swigDoVersionCheck() error {
out, err := b.runOut("", "", nil, "swig", "-version")
out, err := b.runOut("", nil, "swig", "-version")
if err != nil {
return err
}
Expand Down Expand Up @@ -2370,7 +2370,7 @@ func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFL
args = append(args, "-c++")
}

out, err := b.runOut(p.Dir, p.ImportPath, nil, "swig", args, file)
out, err := b.runOut(p.Dir, nil, "swig", args, file)
if err != nil {
if len(out) > 0 {
if bytes.Contains(out, []byte("-intgosize")) || bytes.Contains(out, []byte("-cgo")) {
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/go/internal/work/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, a
args = append(args, mkAbs(p.Dir, f))
}

output, err = b.runOut(p.Dir, p.ImportPath, nil, args...)
output, err = b.runOut(p.Dir, nil, args...)
return ofile, output, err
}

Expand Down Expand Up @@ -289,14 +289,14 @@ func (gcToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) er
if cfg.BuildN {
return nil
}
if err := packInternal(b, absAfile, absOfiles); err != nil {
if err := packInternal(absAfile, absOfiles); err != nil {
b.showOutput(a, p.Dir, p.ImportPath, err.Error()+"\n")
return errPrintedOutput
}
return nil
}

func packInternal(b *Builder, afile string, ofiles []string) error {
func packInternal(afile string, ofiles []string) error {
dst, err := os.OpenFile(afile, os.O_WRONLY|os.O_APPEND, 0)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/go/internal/work/gccgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (tools gccgoToolchain) gc(b *Builder, a *Action, archive string, importcfg
args = append(args, mkAbs(p.Dir, f))
}

output, err = b.runOut(p.Dir, p.ImportPath, nil, args)
output, err = b.runOut(p.Dir, nil, args)
return ofile, output, err
}

Expand Down Expand Up @@ -232,7 +232,7 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string
readAndRemoveCgoFlags := func(archive string) (string, error) {
newID++
newArchive := root.Objdir + fmt.Sprintf("_pkg%d_.a", newID)
if err := b.copyFile(root, newArchive, archive, 0666, false); err != nil {
if err := b.copyFile(newArchive, archive, 0666, false); err != nil {
return "", err
}
if cfg.BuildN || cfg.BuildX {
Expand Down

0 comments on commit 2767c4e

Please sign in to comment.