Skip to content

Commit

Permalink
*: fix naked returns
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <[email protected]>
  • Loading branch information
gyuho committed Nov 11, 2017
1 parent 65a606e commit 75110dd
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 36 deletions.
3 changes: 1 addition & 2 deletions client/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions clientv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contrib/raftexample/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions etcdctl/ctlv3/command/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion etcdserver/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion etcdserver/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion integration/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,5 @@ func (b *bridge) ioCopy(bc *bridgeConn, dst io.Writer, src io.Reader) (err error
break
}
}
return
return err
}
2 changes: 1 addition & 1 deletion integration/embed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/fileutil/lock_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ func lockFileEx(h syscall.Handle, flags, locklow, lockhigh uint32, ol *syscall.O
err = syscall.EINVAL
}
}
return
return err
}
2 changes: 1 addition & 1 deletion pkg/netutil/routes_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions pkg/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -221,7 +221,7 @@ func percentiles(nums []float64) (data []float64) {
j++
}
}
return
return data
}

func (r *report) sprintLatencies() string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/testutil/leak.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,5 @@ func interestingGoroutines() (gs []string) {
gs = append(gs, stack)
}
sort.Strings(gs)
return
return gs
}
2 changes: 1 addition & 1 deletion pkg/transport/keepalive_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/types/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion store/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions tools/etcd-dump-db/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tools/etcd-dump-logs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion wal/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion wal/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion wal/file_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 75110dd

Please sign in to comment.