Skip to content

Commit 6197fbf

Browse files
committed
Merge pull request #2458 from fjl/go-vet
all: fix go vet warnings
2 parents 5c17b2f + bf5ae50 commit 6197fbf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+130
-118
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ test: all
109109
build/env.sh go test ./...
110110

111111
travis-test-with-coverage: all
112+
build/env.sh go vet ./...
112113
build/env.sh build/test-global-coverage.sh
113114

114115
xgo:

accounts/abi/numbers_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ func TestNumberTypes(t *testing.T) {
3030

3131
unsigned := U256(big.NewInt(1))
3232
if !bytes.Equal(unsigned, ubytes) {
33-
t.Error("expected %x got %x", ubytes, unsigned)
33+
t.Errorf("expected %x got %x", ubytes, unsigned)
3434
}
3535

3636
signed := S256(big.NewInt(1))
3737
if !bytes.Equal(signed, ubytes) {
38-
t.Error("expected %x got %x", ubytes, unsigned)
38+
t.Errorf("expected %x got %x", ubytes, unsigned)
3939
}
4040

4141
signed = S256(big.NewInt(-1))
4242
if !bytes.Equal(signed, sbytesmin) {
43-
t.Error("expected %x got %x", ubytes, unsigned)
43+
t.Errorf("expected %x got %x", ubytes, unsigned)
4444
}
4545
}
4646

@@ -75,10 +75,10 @@ func TestPackNumber(t *testing.T) {
7575

7676
func TestSigned(t *testing.T) {
7777
if isSigned(reflect.ValueOf(uint(10))) {
78-
t.Error()
78+
t.Error("signed")
7979
}
8080

8181
if !isSigned(reflect.ValueOf(int(10))) {
82-
t.Error()
82+
t.Error("not signed")
8383
}
8484
}

cmd/bootnode/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func main() {
7979
func writeKey(target string) {
8080
key, err := crypto.GenerateKey()
8181
if err != nil {
82-
log.Fatal("could not generate key: %v", err)
82+
log.Fatalf("could not generate key: %v", err)
8383
}
8484
b := crypto.FromECDSA(key)
8585
if target == "-" {

cmd/ethtest/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ func runTestWithReader(test string, r io.Reader) error {
7676
case "bk", "block", "blocktest", "blockchaintest", "blocktests", "blockchaintests":
7777
err = tests.RunBlockTestWithReader(params.MainNetHomesteadBlock, r, skipTests)
7878
case "st", "state", "statetest", "statetests":
79-
err = tests.RunStateTestWithReader(tests.RuleSet{params.MainNetHomesteadBlock}, r, skipTests)
79+
rs := tests.RuleSet{HomesteadBlock: params.MainNetHomesteadBlock}
80+
err = tests.RunStateTestWithReader(rs, r, skipTests)
8081
case "tx", "transactiontest", "transactiontests":
8182
err = tests.RunTransactionTestsWithReader(r, skipTests)
8283
case "vm", "vmtest", "vmtests":

cmd/geth/js_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *nod
8989
// Initialize and register the Ethereum protocol
9090
accman := accounts.NewPlaintextManager(filepath.Join(tmp, "keystore"))
9191
db, _ := ethdb.NewMemDatabase()
92-
core.WriteGenesisBlockForTesting(db, core.GenesisAccount{common.HexToAddress(testAddress), common.String2Big(testBalance)})
92+
core.WriteGenesisBlockForTesting(db, core.GenesisAccount{
93+
Address: common.HexToAddress(testAddress),
94+
Balance: common.String2Big(testBalance),
95+
})
9396
ethConf := &eth.Config{
9497
ChainConfig: &core.ChainConfig{HomesteadBlock: new(big.Int)},
9598
TestGenesisState: db,

cmd/utils/jeth.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,11 @@ func (self *Jeth) NewAccount(call otto.FunctionCall) (response otto.Value) {
131131
return otto.FalseValue()
132132
}
133133

134-
if ret, err := call.Otto.Call("jeth.newAccount", nil, passwd); err == nil {
134+
ret, err := call.Otto.Call("jeth.newAccount", nil, passwd)
135+
if err == nil {
135136
return ret
136-
} else {
137-
fmt.Printf("%v\n", err)
138-
return otto.FalseValue()
139137
}
140-
138+
fmt.Println(err)
141139
return otto.FalseValue()
142140
}
143141

@@ -233,7 +231,6 @@ func (self *Jeth) Send(call otto.FunctionCall) (response otto.Value) {
233231
func throwJSExeception(msg interface{}) otto.Value {
234232
p, _ := otto.ToValue(msg)
235233
panic(p)
236-
return p
237234
}
238235

239236
// Sleep will halt the console for arg[0] seconds.

common/compiler/solidity_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestCompiler(t *testing.T) {
5757
}
5858

5959
if len(contracts) != 1 {
60-
t.Errorf("one contract expected, got\n%s", len(contracts))
60+
t.Errorf("one contract expected, got %d", len(contracts))
6161
}
6262

6363
if contracts["test"].Code != code {

common/math/dist_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestSum(t *testing.T) {
3535
summer := summer{numbers: []*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)}}
3636
sum := Sum(summer)
3737
if sum.Cmp(big.NewInt(6)) != 0 {
38-
t.Errorf("not 6", sum)
38+
t.Errorf("got sum = %d, want 6", sum)
3939
}
4040
}
4141

common/path.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func MakeName(name, version string) string {
3434

3535
func ExpandHomePath(p string) (path string) {
3636
path = p
37-
sep := fmt.Sprintf("%s", os.PathSeparator)
37+
sep := string(os.PathSeparator)
3838

3939
// Check in case of paths like "/something/~/something/"
4040
if len(p) > 1 && p[:1+len(sep)] == "~"+sep {

core/asm.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,4 @@ func Disassemble(script []byte) (asm []string) {
6161

6262
pc.Add(pc, common.Big1)
6363
}
64-
65-
return asm
6664
}

0 commit comments

Comments
 (0)