mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-24 17:35:01 +01:00
fix unreachable code & missing stringer-generated code
This commit is contained in:
parent
6199595602
commit
0cbee78b40
@ -111,7 +111,6 @@ func (m DatasetMapFilter) Map(source *zfs.DatasetPath) (target *zfs.DatasetPath,
|
||||
mi, hasMapping := m.mostSpecificPrefixMapping(source)
|
||||
if !hasMapping {
|
||||
return nil, nil
|
||||
return
|
||||
}
|
||||
me := m.entries[mi]
|
||||
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"io/ioutil"
|
||||
|
||||
"fmt"
|
||||
yaml "github.com/go-yaml/yaml"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/pkg/errors"
|
||||
yaml "github.com/go-yaml/yaml"
|
||||
"os"
|
||||
)
|
||||
|
||||
@ -99,7 +99,7 @@ func parseConfig(i interface{}) (c *Config, err error) {
|
||||
// Try to find its name
|
||||
namei, ok := asMap.Jobs[i]["name"]
|
||||
if !ok {
|
||||
namei = fmt.Sprintf("<no name, %i in list>", i)
|
||||
namei = fmt.Sprintf("<no name, entry #%d in list>", i)
|
||||
}
|
||||
err = errors.Wrapf(err, "cannot parse job '%v'", namei)
|
||||
return nil, err
|
||||
@ -175,9 +175,6 @@ func parseJob(c JobParsingContext, i map[string]interface{}) (j Job, err error)
|
||||
return nil, errors.Errorf("unknown job type '%s'", jobtype)
|
||||
}
|
||||
|
||||
panic("implementation error")
|
||||
return nil, nil
|
||||
|
||||
}
|
||||
|
||||
func parseConnect(i map[string]interface{}) (c RWCConnecter, err error) {
|
||||
@ -194,8 +191,6 @@ func parseConnect(i map[string]interface{}) (c RWCConnecter, err error) {
|
||||
return nil, errors.Errorf("unknown connection type '%s'", t)
|
||||
}
|
||||
|
||||
panic("implementation error")
|
||||
return
|
||||
}
|
||||
|
||||
func parseInitialReplPolicy(v interface{}, defaultPolicy InitialReplPolicy) (p InitialReplPolicy, err error) {
|
||||
@ -239,9 +234,6 @@ func parsePrunePolicy(v map[string]interface{}) (p PrunePolicy, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
panic("implementation error")
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func parseAuthenticatedChannelListenerFactory(c JobParsingContext, v map[string]interface{}) (p AuthenticatedChannelListenerFactory, err error) {
|
||||
@ -259,7 +251,4 @@ func parseAuthenticatedChannelListenerFactory(c JobParsingContext, v map[string]
|
||||
return
|
||||
}
|
||||
|
||||
panic("implementation error")
|
||||
return
|
||||
|
||||
}
|
||||
|
@ -15,11 +15,11 @@ func ListenUnixPrivate(sockaddr *net.UnixAddr) (*net.UnixListener, error) {
|
||||
return nil, errors.Wrapf(err, "cannot stat(2) '%s'", sockdir)
|
||||
}
|
||||
if !sdstat.IsDir() {
|
||||
return nil, errors.Errorf("%s is not a directory: %s", sockdir)
|
||||
return nil, errors.Errorf("not a directory: %s", sockdir)
|
||||
}
|
||||
p := sdstat.Mode().Perm()
|
||||
if p&0007 != 0 {
|
||||
return nil, errors.Errorf("%s must not be world-accessible (permissions are %#o)", p)
|
||||
return nil, errors.Errorf("socket directory not be world-accessible: %s (permissions are %#o)", sockdir, p)
|
||||
}
|
||||
|
||||
// Maybe things have not been cleaned up before
|
||||
|
@ -310,8 +310,7 @@ func doPull(pull PullContext) (err error) {
|
||||
|
||||
}
|
||||
|
||||
panic("implementation error: this should not be reached")
|
||||
return false
|
||||
panic("should not be reached")
|
||||
|
||||
})
|
||||
|
||||
|
@ -47,7 +47,7 @@ func (l Level) String() string {
|
||||
case Error:
|
||||
return "error"
|
||||
default:
|
||||
return fmt.Sprintf("%s", l)
|
||||
return fmt.Sprintf("%s", string(l))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ func (l *Logger) WithField(field string, val interface{}) *Logger {
|
||||
defer l.mtx.Unlock()
|
||||
|
||||
if _, ok := l.fields[field]; ok {
|
||||
fmt.Fprintf(os.Stderr, "%s caller overwrites field '%s'. Stack:\n%s\n", InternalErrorPrefix, string(debug.Stack()))
|
||||
fmt.Fprintf(os.Stderr, "%s caller overwrites field '%s'. Stack:\n%s\n", InternalErrorPrefix, field, string(debug.Stack()))
|
||||
}
|
||||
|
||||
child := &Logger{
|
||||
|
@ -26,6 +26,7 @@ const (
|
||||
FrameTypeRST FrameType = 0xff
|
||||
)
|
||||
|
||||
//go:generate stringer -type=Status
|
||||
type Status uint64
|
||||
|
||||
const (
|
||||
@ -154,7 +155,7 @@ func (w *frameBridgingWriter) writeUntilFrameFull(b []byte) (n int, err error) {
|
||||
return
|
||||
}
|
||||
if w.bytesLeftToLimit == 0 {
|
||||
err = errors.Errorf("exceeded limit of total %v bytes for this message")
|
||||
err = errors.Errorf("message exceeds max number of allowed bytes")
|
||||
return
|
||||
}
|
||||
maxwrite := len(b)
|
||||
|
27
rpc/frametype_string.go
Normal file
27
rpc/frametype_string.go
Normal file
@ -0,0 +1,27 @@
|
||||
// Code generated by "stringer -type=FrameType"; DO NOT EDIT.
|
||||
|
||||
package rpc
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
_FrameType_name_0 = "FrameTypeHeaderFrameTypeDataFrameTypeTrailer"
|
||||
_FrameType_name_1 = "FrameTypeRST"
|
||||
)
|
||||
|
||||
var (
|
||||
_FrameType_index_0 = [...]uint8{0, 15, 28, 44}
|
||||
_FrameType_index_1 = [...]uint8{0, 12}
|
||||
)
|
||||
|
||||
func (i FrameType) String() string {
|
||||
switch {
|
||||
case 1 <= i && i <= 3:
|
||||
i -= 1
|
||||
return _FrameType_name_0[_FrameType_index_0[i]:_FrameType_index_0[i+1]]
|
||||
case i == 255:
|
||||
return _FrameType_name_1
|
||||
default:
|
||||
return fmt.Sprintf("FrameType(%d)", i)
|
||||
}
|
||||
}
|
@ -28,7 +28,6 @@ func (s *LocalRPC) RegisterEndpoint(name string, handler interface{}) (err error
|
||||
|
||||
func (s *LocalRPC) Serve() (err error) {
|
||||
panic("local cannot serve")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *LocalRPC) Call(endpoint string, in, out interface{}) (err error) {
|
||||
|
@ -160,7 +160,6 @@ func (s *Server) ServeRequest() (err error) {
|
||||
r := NewErrorHeader(StatusRequestError, "unregistered control endpoint %s", h.Endpoint)
|
||||
return s.writeResponse(r)
|
||||
}
|
||||
panic("implementation error")
|
||||
}
|
||||
|
||||
ep, ok := s.endpoints[h.Endpoint]
|
||||
|
17
rpc/status_string.go
Normal file
17
rpc/status_string.go
Normal file
@ -0,0 +1,17 @@
|
||||
// Code generated by "stringer -type=Status"; DO NOT EDIT.
|
||||
|
||||
package rpc
|
||||
|
||||
import "fmt"
|
||||
|
||||
const _Status_name = "StatusOKStatusRequestErrorStatusServerErrorStatusError"
|
||||
|
||||
var _Status_index = [...]uint8{0, 8, 26, 43, 54}
|
||||
|
||||
func (i Status) String() string {
|
||||
i -= 1
|
||||
if i >= Status(len(_Status_index)-1) {
|
||||
return fmt.Sprintf("Status(%d)", i+1)
|
||||
}
|
||||
return _Status_name[_Status_index[i]:_Status_index[i+1]]
|
||||
}
|
@ -25,7 +25,6 @@ func (t VersionType) DelimiterChar() string {
|
||||
default:
|
||||
panic(fmt.Sprintf("unexpected VersionType %#v", t))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type FilesystemVersion struct {
|
||||
|
Loading…
Reference in New Issue
Block a user