Skip to content

Commit

Permalink
*: fix 'ineffassign' issues
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <[email protected]>
  • Loading branch information
gyuho committed Oct 3, 2017
1 parent 72fbe05 commit 0199bdc
Show file tree
Hide file tree
Showing 19 changed files with 38 additions and 23 deletions.
5 changes: 2 additions & 3 deletions client/keys.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ package client
import (
"errors"
"fmt"
codec1978 "github.com/ugorji/go/codec"
"reflect"
"runtime"
time "time"

codec1978 "github.com/ugorji/go/codec"
)

const (
Expand Down Expand Up @@ -77,7 +78,6 @@ func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
}
}
r.EncodeMapStart(yynn2)
yynn2 = 0
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1819)
Expand Down Expand Up @@ -352,7 +352,6 @@ func (x *Node) CodecEncodeSelf(e *codec1978.Encoder) {
}
}
r.EncodeMapStart(yynn2)
yynn2 = 0
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1819)
Expand Down
2 changes: 1 addition & 1 deletion client/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestMain(m *testing.M) {
os.Args = append(os.Args, "-test.run=Test")
}

v := 0
var v int
if useCluster {
tr, trerr := transport.NewTransport(transport.TLSInfo{}, time.Second)
if trerr != nil {
Expand Down
2 changes: 1 addition & 1 deletion clientv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func (c *Client) checkVersion() (err error) {
vs := strings.Split(resp.Version, ".")
maj, min := 0, 0
if len(vs) >= 2 {
maj, rerr = strconv.Atoi(vs[0])
maj, _ = strconv.Atoi(vs[0])
min, rerr = strconv.Atoi(vs[1])
}
if maj < 3 || (maj == 3 && min < 2) {
Expand Down
6 changes: 3 additions & 3 deletions clientv3/integration/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func testWatchCancelRunning(t *testing.T, wctx *watchctx) {
select {
case <-time.After(time.Second):
t.Fatalf("took too long to cancel")
case v, ok := <-wctx.ch:
case _, ok := <-wctx.ch:
if !ok {
// closed before getting put; OK
break
Expand All @@ -320,8 +320,8 @@ func testWatchCancelRunning(t *testing.T, wctx *watchctx) {
select {
case <-time.After(time.Second):
t.Fatalf("took too long to close")
case v, ok = <-wctx.ch:
if ok {
case v, ok2 := <-wctx.ch:
if ok2 {
t.Fatalf("expected watcher channel to close, got %v", v)
}
}
Expand Down
2 changes: 1 addition & 1 deletion clientv3/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestMain(m *testing.M) {
os.Args = append(os.Args, "-test.run=Test")
}

v := 0
var v int
if useCluster {
cfg := integration.ClusterConfig{Size: 3}
clus := integration.NewClusterV3(nil, &cfg)
Expand Down
5 changes: 4 additions & 1 deletion clientv3/naming/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ func TestGRPCResolver(t *testing.T) {

delOp := naming.Update{Op: naming.Delete, Addr: "127.0.0.1"}
err = r.Update(context.TODO(), "foo", delOp)
if err != nil {
t.Fatalf("failed to udpate %v", err)
}

us, err = w.Next()
if err != nil {
t.Fatal("failed to get udpate", err)
t.Fatalf("failed to get udpate %v", err)
}

wu = &naming.Update{
Expand Down
9 changes: 9 additions & 0 deletions clientv3/ordering/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func TestDetectKvOrderViolation(t *testing.T) {
},
}
cli, err := clientv3.New(cfg)
if err != nil {
t.Fatal(err)
}
ctx := context.TODO()

if _, err = clus.Client(0).Put(ctx, "foo", "bar"); err != nil {
Expand Down Expand Up @@ -101,6 +104,9 @@ func TestDetectTxnOrderViolation(t *testing.T) {
},
}
cli, err := clientv3.New(cfg)
if err != nil {
t.Fatal(err)
}
ctx := context.TODO()

if _, err = clus.Client(0).Put(ctx, "foo", "bar"); err != nil {
Expand Down Expand Up @@ -143,6 +149,9 @@ func TestDetectTxnOrderViolation(t *testing.T) {
cli.SetEndpoints(clus.Members[2].GRPCAddr())

_, err = orderingKv.Get(ctx, "foo", clientv3.WithSerializable())
if err != nil {
t.Fatal(err)
}
orderingTxn = orderingKv.Txn(ctx)
_, err = orderingTxn.If(
clientv3.Compare(clientv3.Value("b"), ">", "a"),
Expand Down
6 changes: 6 additions & 0 deletions clientv3/ordering/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func TestEndpointSwitchResolvesViolation(t *testing.T) {
}
cfg := clientv3.Config{Endpoints: []string{clus.Members[0].GRPCAddr()}}
cli, err := clientv3.New(cfg)
if err != nil {
t.Fatal(err)
}

ctx := context.TODO()

Expand Down Expand Up @@ -91,6 +94,9 @@ func TestUnresolvableOrderViolation(t *testing.T) {
},
}
cli, err := clientv3.New(cfg)
if err != nil {
t.Fatal(err)
}
eps := cli.Endpoints()
ctx := context.TODO()

Expand Down
1 change: 0 additions & 1 deletion compactor/revision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func TestRevision(t *testing.T) {

// skip the same revision
rg.SetRev(99) // will be 100
expectedRevision = int64(90)
rg.Wait(1)
// nothing happens

Expand Down
2 changes: 1 addition & 1 deletion e2e/ctl_v3_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func ctlV3RoleRevokePermission(cx ctlCtx, rolename string, key, rangeEnd string,
cmdArgs := append(cx.PrefixArgs(), "role", "revoke-permission")
cmdArgs = append(cmdArgs, rolename)
cmdArgs = append(cmdArgs, key)
expStr := ""
var expStr string
if len(rangeEnd) != 0 {
cmdArgs = append(cmdArgs, rangeEnd)
expStr = fmt.Sprintf("Permission of range [%s, %s) is revoked from role %s", key, rangeEnd, rolename)
Expand Down
2 changes: 1 addition & 1 deletion e2e/etcd_spawn_cov.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func spawnEtcd(args []string) (*expect.ExpectProcess, error) {
return nil, err
}

env := []string{}
var env []string
if args[1] == "grpc-proxy" {
// avoid test flag conflicts in coverage enabled etcd by putting flags in ETCDCOV_ARGS
env = append(os.Environ(), "ETCDCOV_ARGS="+strings.Join(args, "\xe7\xcd"))
Expand Down
2 changes: 1 addition & 1 deletion etcdctl/ctlv3/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func etcdFlagUsages(flagSet *pflag.FlagSet) string {
if len(flag.Deprecated) > 0 {
return
}
format := ""
var format string
if len(flag.Shorthand) > 0 {
format = " -%s, --%s"
} else {
Expand Down
2 changes: 1 addition & 1 deletion etcdserver/api/v2http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (h *statsHandler) serveLeader(w http.ResponseWriter, r *http.Request) {
// a server Request, performing validation of supplied fields as appropriate.
// If any validation fails, an empty Request and non-nil error is returned.
func parseKeyRequest(r *http.Request, clock clockwork.Clock) (etcdserverpb.Request, bool, error) {
noValueOnSuccess := false
var noValueOnSuccess bool
emptyReq := etcdserverpb.Request{}

err := r.ParseForm()
Expand Down
3 changes: 1 addition & 2 deletions etcdserver/api/v2v3/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ func (s *v2v3Store) Delete(nodePath string, dir, recursive bool) (*store.Event,
if !dir && !recursive {
return s.deleteNode(nodePath)
}
dir = true
if !recursive {
return s.deleteEmptyDir(nodePath)
}
Expand Down Expand Up @@ -516,7 +515,7 @@ func compareFail(nodePath, prevValue string, prevIndex uint64, resp *clientv3.Tx
kv := kvs[0]
indexMatch := (prevIndex == 0 || kv.ModRevision == int64(prevIndex))
valueMatch := (prevValue == "" || string(kv.Value) == prevValue)
cause := ""
var cause string
switch {
case indexMatch && !valueMatch:
cause = fmt.Sprintf("[%v != %v]", prevValue, string(kv.Value))
Expand Down
2 changes: 1 addition & 1 deletion proxy/tcpproxy/userspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (tp *TCPProxy) pick() *remote {
case r.srv.Priority < bestPr:
bestPr = r.srv.Priority
w = 0
weighted, unweighted = nil, nil
weighted = nil
unweighted = []*remote{r}
fallthrough
case r.srv.Priority == bestPr:
Expand Down
3 changes: 2 additions & 1 deletion raft/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ func (in *inflights) freeTo(to uint64) {
return
}

i, idx := 0, in.start
idx := in.start
var i int
for i = 0; i < in.count; i++ {
if to < in.buffer[idx] { // found the first large inflight
break
Expand Down
1 change: 0 additions & 1 deletion store/store_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ func benchStoreSet(b *testing.B, valueSize int, process func(interface{}) ([]byt
}
}

kvs = nil
b.StopTimer()
memStats := new(runtime.MemStats)
runtime.GC()
Expand Down
4 changes: 2 additions & 2 deletions store/store_ttl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func TestStoreWatchExpireEmptyRefresh(t *testing.T) {
fc := newFakeClock()
s.clock = fc

var eidx uint64 = 1
var eidx uint64
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
// Should be no-op
fc.Advance(200 * time.Millisecond)
Expand All @@ -241,7 +241,7 @@ func TestStoreWatchNoRefresh(t *testing.T) {
fc := newFakeClock()
s.clock = fc

var eidx uint64 = 1
var eidx uint64
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
// Should be no-op
fc.Advance(200 * time.Millisecond)
Expand Down
2 changes: 1 addition & 1 deletion tools/functional-tester/etcd-runner/command/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func etcdFlagUsages(flagSet *pflag.FlagSet) string {
if len(flag.Deprecated) > 0 {
return
}
format := ""
var format string
if len(flag.Shorthand) > 0 {
format = " -%s, --%s"
} else {
Expand Down

0 comments on commit 0199bdc

Please sign in to comment.