瀏覽代碼

*: fix go vet reported issues

Cong Ding 10 年之前
父節點
當前提交
c09b667d57

+ 0 - 1
etcdserver/api/v3rpc/key.go

@@ -50,5 +50,4 @@ func (h *handler) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, e
 
 func (h *handler) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
 	panic("not implemented")
-	return nil, nil
 }

+ 0 - 2
pkg/testutil/pauseable_handler.go

@@ -35,12 +35,10 @@ func (ph *PauseableHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 		hj, ok := w.(http.Hijacker)
 		if !ok {
 			panic("webserver doesn't support hijacking")
-			return
 		}
 		conn, _, err := hj.Hijack()
 		if err != nil {
 			panic(err.Error())
-			return
 		}
 		conn.Close()
 	}

+ 1 - 1
raft/rafttest/network_test.go

@@ -32,7 +32,7 @@ func TestNetworkDrop(t *testing.T) {
 
 	drop := sent - received
 	if drop > int((droprate+0.1)*float64(sent)) || drop < int((droprate-0.1)*float64(sent)) {
-		t.Errorf("drop = %d, want around %d", drop, droprate*float64(sent))
+		t.Errorf("drop = %d, want around %.2f", drop, droprate*float64(sent))
 	}
 }
 

+ 1 - 1
storage/key_index.go

@@ -130,7 +130,7 @@ func (ki *keyIndex) get(atRev int64) (modified, created revision, ver int64, err
 // If a generation becomes empty during compaction, it will be removed.
 func (ki *keyIndex) compact(atRev int64, available map[revision]struct{}) {
 	if ki.isEmpty() {
-		log.Panic("store.keyindex: unexpected compact on empty keyIndex %s", string(ki.key))
+		log.Panicf("store.keyindex: unexpected compact on empty keyIndex %s", string(ki.key))
 	}
 
 	// walk until reaching the first revision that has an revision smaller or equal to

+ 2 - 2
storage/key_index_test.go

@@ -293,14 +293,14 @@ func TestKeyIndexCompact(t *testing.T) {
 
 	// Jump Compaction
 	for i, tt := range tests {
-		if (i%2 == 0 && i < 6) && (i%2 == 1 && i > 6) {
+		if (i%2 == 0 && i < 6) || (i%2 == 1 && i > 6) {
 			am := make(map[revision]struct{})
 			ki.compact(tt.compact, am)
 			if !reflect.DeepEqual(ki, tt.wki) {
 				t.Errorf("#%d: ki = %+v, want %+v", i, ki, tt.wki)
 			}
 			if !reflect.DeepEqual(am, tt.wam) {
-				t.Errorf("#%d: am = %+v, want %+v", am, tt.wam)
+				t.Errorf("#%d: am = %+v, want %+v", i, am, tt.wam)
 			}
 		}
 	}

+ 1 - 1
storage/kv_test.go

@@ -42,7 +42,7 @@ func TestWorkflow(t *testing.T) {
 		// check existing keys
 		kvs, rev, err := s.Range([]byte("bar"), []byte("bas"), 0, 0)
 		if err != nil {
-			t.Errorf("#%d: range error (%v)", err)
+			t.Errorf("#%d: range error (%v)", i, err)
 		}
 		if len(kvs) != len(wkvs) {
 			t.Fatalf("#%d: len(kvs) = %d, want %d", i, len(kvs), len(wkvs))