Browse Source

*: fix naked returns

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
Gyu-Ho Lee 8 years ago
parent
commit
75110dd839

+ 1 - 2
client/keys.go

@@ -653,8 +653,7 @@ func unmarshalHTTPResponse(code int, header http.Header, body []byte) (res *Resp
 	default:
 		err = unmarshalFailedKeysResponse(body)
 	}
-
-	return
+	return res, err
 }
 
 func unmarshalSuccessfulKeysResponse(header http.Header, body []byte) (*Response, error) {

+ 3 - 3
clientv3/client.go

@@ -192,7 +192,7 @@ func parseEndpoint(endpoint string) (proto string, host string, scheme string) {
 	host = endpoint
 	url, uerr := url.Parse(endpoint)
 	if uerr != nil || !strings.Contains(endpoint, "://") {
-		return
+		return proto, host, scheme
 	}
 	scheme = url.Scheme
 
@@ -206,7 +206,7 @@ func parseEndpoint(endpoint string) (proto string, host string, scheme string) {
 	default:
 		proto, host = "", ""
 	}
-	return
+	return proto, host, scheme
 }
 
 func (c *Client) processCreds(scheme string) (creds *credentials.TransportCredentials) {
@@ -225,7 +225,7 @@ func (c *Client) processCreds(scheme string) (creds *credentials.TransportCreden
 	default:
 		creds = nil
 	}
-	return
+	return creds
 }
 
 // dialSetupOpts gives the dial opts prior to any authentication

+ 1 - 1
contrib/raftexample/raft.go

@@ -133,7 +133,7 @@ func (rc *raftNode) entriesToApply(ents []raftpb.Entry) (nents []raftpb.Entry) {
 	if rc.appliedIndex-firstIdx+1 < uint64(len(ents)) {
 		nents = ents[rc.appliedIndex-firstIdx+1:]
 	}
-	return
+	return nents
 }
 
 // publishEntries writes committed log entries to commit channel and returns

+ 6 - 6
embed/etcd.go

@@ -108,10 +108,10 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
 	}()
 
 	if e.Peers, err = startPeerListeners(cfg); err != nil {
-		return
+		return e, err
 	}
 	if e.sctxs, err = startClientListeners(cfg); err != nil {
-		return
+		return e, err
 	}
 	for _, sctx := range e.sctxs {
 		e.Clients = append(e.Clients, sctx.l)
@@ -177,7 +177,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
 	}
 
 	if e.Server, err = etcdserver.NewServer(srvcfg); err != nil {
-		return
+		return e, err
 	}
 
 	// buffer channel so goroutines on closed connections won't wait forever
@@ -190,7 +190,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
 	var peerTLScfg *tls.Config
 	if !cfg.PeerTLSInfo.Empty() {
 		if peerTLScfg, err = cfg.PeerTLSInfo.ServerConfig(); err != nil {
-			return
+			return e, err
 		}
 	}
 	for _, p := range e.Peers {
@@ -214,10 +214,10 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
 	}
 
 	if err = e.serve(); err != nil {
-		return
+		return e, err
 	}
 	serving = true
-	return
+	return e, nil
 }
 
 // Config returns the current configuration.

+ 4 - 4
etcdctl/ctlv3/command/printer.go

@@ -169,7 +169,7 @@ func makeMemberListTable(r v3.MemberListResponse) (hdr []string, rows [][]string
 			strings.Join(m.ClientURLs, ","),
 		})
 	}
-	return
+	return hdr, rows
 }
 
 func makeEndpointStatusTable(statusList []epStatus) (hdr []string, rows [][]string) {
@@ -185,7 +185,7 @@ func makeEndpointStatusTable(statusList []epStatus) (hdr []string, rows [][]stri
 			fmt.Sprint(status.Resp.RaftIndex),
 		})
 	}
-	return
+	return hdr, rows
 }
 
 func makeEndpointHashKVTable(hashList []epHashKV) (hdr []string, rows [][]string) {
@@ -196,7 +196,7 @@ func makeEndpointHashKVTable(hashList []epHashKV) (hdr []string, rows [][]string
 			fmt.Sprint(h.Resp.Hash),
 		})
 	}
-	return
+	return hdr, rows
 }
 
 func makeDBStatusTable(ds dbstatus) (hdr []string, rows [][]string) {
@@ -207,5 +207,5 @@ func makeDBStatusTable(ds dbstatus) (hdr []string, rows [][]string) {
 		fmt.Sprint(ds.TotalKey),
 		humanize.Bytes(uint64(ds.TotalSize)),
 	})
-	return
+	return hdr, rows
 }

+ 1 - 1
etcdserver/raft.go

@@ -416,7 +416,7 @@ func startNode(cfg ServerConfig, cl *membership.RaftCluster, ids []types.ID) (id
 	raftStatus = n.Status
 	raftStatusMu.Unlock()
 	advanceTicksForElection(n, c.ElectionTick)
-	return
+	return id, n, s, w
 }
 
 func restartNode(cfg ServerConfig, snapshot *raftpb.Snapshot) (types.ID, *membership.RaftCluster, raft.Node, *raft.MemoryStorage, *wal.WAL) {

+ 1 - 1
etcdserver/storage.go

@@ -94,5 +94,5 @@ func readWAL(waldir string, snap walpb.Snapshot) (w *wal.WAL, id, cid types.ID,
 	pbutil.MustUnmarshal(&metadata, wmetadata)
 	id = types.ID(metadata.NodeID)
 	cid = types.ID(metadata.ClusterID)
-	return
+	return w, id, cid, st, ents
 }

+ 1 - 1
integration/bridge.go

@@ -224,5 +224,5 @@ func (b *bridge) ioCopy(bc *bridgeConn, dst io.Writer, src io.Reader) (err error
 			break
 		}
 	}
-	return
+	return err
 }

+ 1 - 1
integration/embed_test.go

@@ -151,7 +151,7 @@ func newEmbedURLs(n int) (urls []url.URL) {
 		u, _ := url.Parse(fmt.Sprintf("unix://localhost:%d%06d", os.Getpid(), i))
 		urls = append(urls, *u)
 	}
-	return
+	return urls
 }
 
 func setupEmbedCfg(cfg *embed.Config, curls []url.URL, purls []url.URL) {

+ 1 - 1
pkg/fileutil/lock_windows.go

@@ -121,5 +121,5 @@ func lockFileEx(h syscall.Handle, flags, locklow, lockhigh uint32, ol *syscall.O
 			err = syscall.EINVAL
 		}
 	}
-	return
+	return err
 }

+ 1 - 1
pkg/netutil/routes_linux.go

@@ -246,5 +246,5 @@ func parsePREFSRC(m *syscall.NetlinkMessage) (host string, oif uint32, err error
 	if oif == 0 {
 		err = errNoDefaultRoute
 	}
-	return
+	return host, oif, err
 }

+ 3 - 3
pkg/report/report.go

@@ -127,13 +127,13 @@ func copyMap(m map[string]int) (c map[string]int) {
 	for k, v := range m {
 		c[k] = v
 	}
-	return
+	return c
 }
 
 func copyFloats(s []float64) (c []float64) {
 	c = make([]float64, len(s))
 	copy(c, s)
-	return
+	return c
 }
 
 func (r *report) String() (s string) {
@@ -221,7 +221,7 @@ func percentiles(nums []float64) (data []float64) {
 			j++
 		}
 	}
-	return
+	return data
 }
 
 func (r *report) sprintLatencies() string {

+ 1 - 1
pkg/testutil/leak.go

@@ -135,5 +135,5 @@ func interestingGoroutines() (gs []string) {
 		gs = append(gs, stack)
 	}
 	sort.Strings(gs)
-	return
+	return gs
 }

+ 1 - 1
pkg/transport/keepalive_listener.go

@@ -79,7 +79,7 @@ func (l *tlsKeepaliveListener) Accept() (c net.Conn, err error) {
 	kac.SetKeepAlive(true)
 	kac.SetKeepAlivePeriod(30 * time.Second)
 	c = tls.Server(c, l.config)
-	return
+	return c, nil
 }
 
 // NewListener creates a Listener which accepts connections from an inner

+ 2 - 2
pkg/types/set.go

@@ -61,7 +61,7 @@ func (us *unsafeSet) Remove(value string) {
 // Contains returns whether the set contains the given value
 func (us *unsafeSet) Contains(value string) (exists bool) {
 	_, exists = us.d[value]
-	return
+	return exists
 }
 
 // ContainsAll returns whether the set contains all given values
@@ -94,7 +94,7 @@ func (us *unsafeSet) Values() (values []string) {
 	for val := range us.d {
 		values = append(values, val)
 	}
-	return
+	return values
 }
 
 // Copy creates a new Set containing the values of the first

+ 1 - 1
store/node.go

@@ -350,7 +350,7 @@ func (n *node) Compare(prevValue string, prevIndex uint64) (ok bool, which int)
 	default:
 		which = CompareNotMatch
 	}
-	return
+	return ok, which
 }
 
 // Clone function clone the node recursively and return the new node.

+ 2 - 2
tools/etcd-dump-db/backend.go

@@ -40,7 +40,7 @@ func getBuckets(dbPath string) (buckets []string, err error) {
 			return nil
 		})
 	})
-	return
+	return buckets, err
 }
 
 func iterateBucket(dbPath, bucket string, limit uint64) (err error) {
@@ -70,7 +70,7 @@ func iterateBucket(dbPath, bucket string, limit uint64) (err error) {
 
 		return nil
 	})
-	return
+	return err
 }
 
 func getHash(dbPath string) (hash uint32, err error) {

+ 1 - 1
tools/etcd-dump-logs/main.go

@@ -141,7 +141,7 @@ func parseWALMetadata(b []byte) (id, cid types.ID) {
 	pbutil.MustUnmarshal(&metadata, b)
 	id = types.ID(metadata.NodeID)
 	cid = types.ID(metadata.ClusterID)
-	return
+	return id, cid
 }
 
 func genIDSlice(a []uint64) []types.ID {

+ 1 - 1
wal/decoder.go

@@ -119,7 +119,7 @@ func decodeFrameSize(lenField int64) (recBytes int64, padBytes int64) {
 		// padding is stored in lower 3 bits of length MSB
 		padBytes = int64((uint64(lenField) >> 56) & 0x7)
 	}
-	return
+	return recBytes, padBytes
 }
 
 // isTornEntry determines whether the last entry of the WAL was partially written

+ 1 - 1
wal/encoder.go

@@ -103,7 +103,7 @@ func encodeFrameSize(dataBytes int) (lenField uint64, padBytes int) {
 	if padBytes != 0 {
 		lenField |= uint64(0x80|padBytes) << 56
 	}
-	return
+	return lenField, padBytes
 }
 
 func (e *encoder) flush() error {

+ 1 - 1
wal/file_pipeline.go

@@ -55,7 +55,7 @@ func (fp *filePipeline) Open() (f *fileutil.LockedFile, err error) {
 	case f = <-fp.filec:
 	case err = <-fp.errc:
 	}
-	return
+	return f, err
 }
 
 func (fp *filePipeline) Close() error {