fix(code scan): fix code-scanning problems.

Signed-off-by: lily-lee <lilylee88756@gmail.com>
This commit is contained in:
lily-lee 2023-11-27 17:28:16 +08:00 committed by leonrayang
parent 894c4ac0b4
commit a8620dc1e9
60 changed files with 251 additions and 86 deletions

View File

@ -275,6 +275,8 @@ func (m *Server) apiAccessEntry(w http.ResponseWriter, r *http.Request) {
newKeyInfo, err = m.handleDeleteCaps(&keyInfo)
case proto.MsgAuthGetCapsReq:
newKeyInfo, err = m.handleGetCaps(&keyInfo)
default:
// do nothing
}
if err != nil {
@ -423,6 +425,8 @@ func (m *Server) osCapsOp(w http.ResponseWriter, r *http.Request) {
newAkCaps, err = m.handleOSDeleteCaps(&akCaps)
case proto.MsgAuthOSGetCapsReq:
newAkCaps, err = m.handleOSGetCaps(&akCaps)
default:
// do nothing
}
if err != nil {

View File

@ -63,6 +63,8 @@ func (m *Server) handlePeerChange(confChange *proto.ConfChange) (err error) {
case proto.ConfRemoveNode:
m.raftStore.DeleteNode(confChange.Peer.ID)
msg = fmt.Sprintf("clusterID[%v] peerID:%v,nodeAddr[%v] has been removed", m.clusterName, confChange.Peer.ID, addr)
default:
// do nothing
}
log.LogWarnf(msg)
return

View File

@ -404,6 +404,8 @@ func accessAuthServer() {
panic(err)
}
fmt.Printf(res + "\n")
default:
// do nothing
}
return

View File

@ -166,7 +166,9 @@ func initCC() {
c, stop := newCCStop()
if cc == nil {
cc = c
stop = func() {}
stop = func() {
// do nothing
}
}
clusters := c.All()
@ -174,16 +176,7 @@ func initCC() {
case 0:
cc0 = c
case 1:
switch clusters[0].ClusterID {
case 1:
cc1 = c
case 2:
cc2 = c
case 3:
cc3 = c
default:
stop()
}
cc1, cc2, cc3 = handleClusterId(c, cc1, cc2, cc3, clusters[0].ClusterID, stop)
default:
stop()
}
@ -212,6 +205,21 @@ func initCC() {
}
}
func handleClusterId(c, cc1, cc2, cc3 controller.ClusterController, clusterId proto.ClusterID, stop func()) (c1, c2, c3 controller.ClusterController) {
c1, c2, c3 = cc1, cc2, cc3
switch clusterId {
case 1:
c1 = c
case 2:
c2 = c
case 3:
c3 = c
default:
stop()
}
return
}
func newCC() controller.ClusterController {
cc, _ := newCCStop()
return cc

View File

@ -748,6 +748,8 @@ func TestAccessClientPutTimeout(t *testing.T) {
cfg.ClientTimeoutMs = linearTimeoutMs(3, float64(cs.size), 40)
case access.DefaultConnMode:
cfg.ClientTimeoutMs = linearTimeoutMs(30, float64(cs.size), 10)
default:
// do nothing
}
client, err := access.New(cfg)
require.NoError(t, err)

View File

@ -293,6 +293,8 @@ func (qos *IoQueueQos) TryAcquireIO(ctx context.Context, chunkId uint64, rwType
ret = qos.writeDiscard[idx].tryAcquire(ctx)
case ReadType:
ret = qos.readDiscard.tryAcquire(ctx)
default:
// do nothing
}
return ret
}
@ -304,6 +306,8 @@ func (qos *IoQueueQos) ReleaseIO(chunkId uint64, rwType IOTypeRW) {
qos.writeDiscard[idx].release()
case ReadType:
qos.readDiscard.release()
default:
// do nothing
}
qos.Release()
}

View File

@ -118,6 +118,7 @@ func (mock *diskMock) ListChunks(ctx context.Context) (chunks []core.VuidMeta, e
}
func (mock *diskMock) EnqueueCompact(ctx context.Context, vuid proto.Vuid) {
// do nothing
}
func (mock *diskMock) GcRubbishChunk(ctx context.Context) (mayBeLost []bnapi.ChunkId, err error) {
@ -129,9 +130,11 @@ func (mock *diskMock) WalkChunksWithLock(ctx context.Context, fn func(cs core.Ch
}
func (mock *diskMock) ResetChunks(ctx context.Context) {
// do nothing
}
func (mock *diskMock) Close(ctx context.Context) {
// do nothing
}
func ensureTestDir(t *testing.T, diskRoot string) (root, meta, data string) {

View File

@ -38,7 +38,9 @@ func TestInitConfig(t *testing.T) {
err = InitConfig(conf)
require.Error(t, err)
conf.HandleIOError = func(ctx context.Context, diskID proto.DiskID, diskErr error) {}
conf.HandleIOError = func(ctx context.Context, diskID proto.DiskID, diskErr error) {
// do nothing
}
err = InitConfig(conf)
require.Error(t, err)
}

View File

@ -44,6 +44,7 @@ func getDiskIDFn(ctx context.Context) (proto.DiskID, error) {
}
func handleIOErrorFn(ctx context.Context, diskID proto.DiskID, diskErr error) {
// do nothing
}
func setChunkCompactFn(ctx context.Context, args *cmapi.SetCompactChunkArgs) (err error) {

View File

@ -73,6 +73,7 @@ func (mm *mockBrokenMeta) Destroy(ctx context.Context) (err error) {
}
func (mm *mockBrokenMeta) Close() {
// do nothing
}
func (mm *mockBrokenData) Write(ctx context.Context, shard *core.Shard) error {
@ -108,6 +109,7 @@ func (mm *mockBrokenData) Destroy(ctx context.Context) (err error) {
}
func (mm *mockBrokenData) Close() {
// do nothing
}
func TestReplStorage_Operations(t *testing.T) {

View File

@ -113,6 +113,7 @@ func (mm *mockmeta) Destroy(ctx context.Context) (err error) {
}
func (mm *mockmeta) Close() {
// do nothing
}
func (mm *mockdata) Write(ctx context.Context, shard *core.Shard) error {
@ -145,6 +146,7 @@ func (mm *mockdata) Destroy(ctx context.Context) (err error) {
}
func (mm *mockdata) Close() {
// do nothing
}
func TestNewStorage(t *testing.T) {

View File

@ -656,9 +656,11 @@ func (mcm *mockClusterMgr) DiskSet(c *rpc.Context) {
}
func (mcm *mockClusterMgr) ChunkReport(c *rpc.Context) {
// do nothing
}
func (mcm *mockClusterMgr) ServiceRegister(c *rpc.Context) {
// do nothing
}
func (mcm *mockClusterMgr) VolumeGet(c *rpc.Context) {

View File

@ -105,6 +105,8 @@ func (m *mockScheCli) AcquireTask(ctx context.Context, args *scheduler.AcquireAr
task.TaskType = proto.TaskTypeDiskDrop
task.TaskID = fmt.Sprintf("disk_drop_%d", m.migrateID)
m.diskDropTaskCnt++
default:
// do nothing
}
return &task, nil
}

View File

@ -167,7 +167,9 @@ type mockWriter struct{}
func (mockWriter) Write(data []byte) (int, error) { return len(data), nil }
func (mockWriter) Header() http.Header { return http.Header{} }
func (mockWriter) WriteHeader(statusCode int) {}
func (mockWriter) WriteHeader(statusCode int) {
// do nothing
}
func TestNewService(t *testing.T) {
cfg := *testServiceCfg

View File

@ -366,31 +366,7 @@ func (s *instance) writeLoop() {
wb.DeleteRangeCF(rangeDeleteData.cf, rangeDeleteData.start, rangeDeleteData.end)
case batchEvent:
b := task.data.([]batch)
for _, item := range b {
switch item.typ {
case putEvent:
putData := item.data.(put)
wb.Put(putData.key, putData.value)
case deleteEvent:
delData := item.data.(del)
wb.Delete(delData.key)
case rangeDeleteEvent:
rangeDeleteData := item.data.(rangeDelete)
wb.DeleteRange(rangeDeleteData.start, rangeDeleteData.end)
case cfPutEvent:
putData := item.data.(cfPut)
wb.PutCF(putData.cf, putData.key, putData.value)
case cfDeleteEvent:
delData := item.data.(cfDel)
wb.DeleteCF(delData.cf, delData.key)
case cfRangeDeleteEvent:
rangeDeleteData := item.data.(cfRangeDelete)
wb.DeleteRangeCF(rangeDeleteData.cf, rangeDeleteData.start, rangeDeleteData.end)
default:
// never to here
panic("invalid type")
}
}
s.handleBatchEvent(b, wb)
case flushEvent:
if wb.Count() > 0 {
err := s.db.Write(s.wo, wb)
@ -416,6 +392,34 @@ func (s *instance) writeLoop() {
}
}
func (s *instance) handleBatchEvent(b []batch, wb *rdb.WriteBatch) {
for _, item := range b {
switch item.typ {
case putEvent:
putData := item.data.(put)
wb.Put(putData.key, putData.value)
case deleteEvent:
delData := item.data.(del)
wb.Delete(delData.key)
case rangeDeleteEvent:
rangeDeleteData := item.data.(rangeDelete)
wb.DeleteRange(rangeDeleteData.start, rangeDeleteData.end)
case cfPutEvent:
putData := item.data.(cfPut)
wb.PutCF(putData.cf, putData.key, putData.value)
case cfDeleteEvent:
delData := item.data.(cfDel)
wb.DeleteCF(delData.cf, delData.key)
case cfRangeDeleteEvent:
rangeDeleteData := item.data.(cfRangeDelete)
wb.DeleteRangeCF(rangeDeleteData.cf, rangeDeleteData.start, rangeDeleteData.end)
default:
// never to here
panic("invalid type")
}
}
}
func (s *instance) Table(name string) KVTable {
s.lock.RLock()
if t, ok := s.cfTables[name]; ok {
@ -610,6 +614,7 @@ func (wb *WriteBatch) Count() int {
}
func (wb *WriteBatch) Destroy() {
// do nothing
}
func (wb *WriteBatch) Clear() {

View File

@ -39,6 +39,7 @@ func (sm *configSM) ApplySnapshot(meta SnapshotMeta, st Snapshot) error {
}
func (sm *configSM) LeaderChange(leader uint64, host string) {
// do nothing
}
func TestConfig(t *testing.T) {

View File

@ -46,6 +46,7 @@ func (s *testSnapshot) Read() ([]byte, error) {
}
func (s *testSnapshot) Close() {
// do nothing
}
func TestSnapshotter(t *testing.T) {

View File

@ -50,6 +50,7 @@ func (s *storeSnapshot) Read() ([]byte, error) {
}
func (s *storeSnapshot) Close() {
// do nothing
}
type storeSM struct {
@ -79,6 +80,7 @@ func (sm *storeSM) ApplySnapshot(meta SnapshotMeta, st Snapshot) error {
}
func (sm *storeSM) LeaderChange(leader uint64, host string) {
// do nothing
}
func TestStorage(t *testing.T) {

View File

@ -236,6 +236,8 @@ func parse(operation, field, value string) (condFunc, error) {
getIntField = func(log *AuditLog) int64 { return log.RespLength }
case "duration", "Duration":
getIntField = func(log *AuditLog) int64 { return log.Duration }
default:
// do nothing
}
if getStrField != nil {

View File

@ -31,7 +31,9 @@ func TestServerRecovery(t *testing.T) {
router.Use(func(c *Context) {
panic("in interceptor")
})
router.Handle(http.MethodGet, "/", func(c *Context) {})
router.Handle(http.MethodGet, "/", func(c *Context) {
// do nothing
})
w := new(mockResponseWriter)
req, _ := http.NewRequest(http.MethodGet, "/", nil)
@ -42,7 +44,9 @@ func TestServerRecovery(t *testing.T) {
{
router := New()
router.Router.PanicHandler = defaultRecovery
router.Use(func(c *Context) {})
router.Use(func(c *Context) {
// do nothing
})
router.Handle(http.MethodGet, "/", func(c *Context) {
panic("in app")
})
@ -56,7 +60,9 @@ func TestServerRecovery(t *testing.T) {
{
router := New()
router.Router.PanicHandler = defaultRecovery
router.Use(func(c *Context) {})
router.Use(func(c *Context) {
// do nothing
})
router.Handle(http.MethodGet, "/", func(c *Context) {
panic(&net.OpError{
Err: &os.SyscallError{
@ -83,7 +89,9 @@ func TestServerRecovery(t *testing.T) {
},
})
})
router.Handle(http.MethodGet, "/", func(c *Context) {})
router.Handle(http.MethodGet, "/", func(c *Context) {
// do nothing
})
w := new(mockResponseWriter)
req, _ := http.NewRequest(http.MethodGet, "/", nil)

View File

@ -64,13 +64,17 @@ func TestServerRouterMaxHandlers(t *testing.T) {
{
router := New()
router.Use(make([]HandlerFunc, abortIndex-2)...)
router.Handle(http.MethodGet, "/", func(c *Context) {})
router.Handle(http.MethodGet, "/", func(c *Context) {
// do nothing
})
}
{
router := New()
router.Use(make([]HandlerFunc, abortIndex-1)...)
require.Panics(t, func() {
router.Handle(http.MethodGet, "/", func(c *Context) {})
router.Handle(http.MethodGet, "/", func(c *Context) {
// do nothing
})
})
}
{

View File

@ -134,7 +134,9 @@ func TestServerAbortStatus(t *testing.T) {
{
router := New()
router.Use(func(c *Context) {})
router.Use(func(c *Context) {
// do nothing
})
router.Handle(http.MethodGet, "/", func(c *Context) { c.Respond() })
w := resp(router)
require.Equal(t, 200, w.status)
@ -142,7 +144,9 @@ func TestServerAbortStatus(t *testing.T) {
}
{
router := New()
router.Use(func(c *Context) {})
router.Use(func(c *Context) {
// do nothing
})
router.Handle(http.MethodGet, "/", func(c *Context) { c.RespondStatus(200) })
w := resp(router)
require.Equal(t, 200, w.status)
@ -150,8 +154,12 @@ func TestServerAbortStatus(t *testing.T) {
}
{
router := New()
router.Use(func(c *Context) {})
router.Handle(http.MethodGet, "/", func(c *Context) {})
router.Use(func(c *Context) {
// do nothing
})
router.Handle(http.MethodGet, "/", func(c *Context) {
// do nothing
})
w := resp(router)
require.Equal(t, 200, w.status)
require.Equal(t, "", w.Header().Get(HeaderContentLength))
@ -363,7 +371,9 @@ func TestServerResponseWith(t *testing.T) {
{
router := New()
router.Use(func(c *Context) {})
router.Use(func(c *Context) {
// do nothing
})
router.Handle(http.MethodGet, "/", func(c *Context) { c.Respond() })
w := resp(router)
require.Equal(t, 0, len(w.body))
@ -377,7 +387,9 @@ func TestServerResponseWith(t *testing.T) {
}
{
router := New()
router.Use(func(c *Context) {})
router.Use(func(c *Context) {
// do nothing
})
router.Handle(http.MethodGet, "/", func(c *Context) { c.RespondStatusData(255, nil) })
w := resp(router)
require.Equal(t, 255, w.status)
@ -385,7 +397,9 @@ func TestServerResponseWith(t *testing.T) {
}
{
router := New()
router.Use(func(c *Context) {})
router.Use(func(c *Context) {
// do nothing
})
router.Handle(http.MethodGet, "/", func(c *Context) { c.RespondStatusData(255, NoneBody) })
w := resp(router)
require.Equal(t, 255, w.status)

View File

@ -445,6 +445,8 @@ func (mgr *BlobDeleteMgr) recordAllResult(rets []delBlobRet) {
span.Warnf("unexpected result will ignore: msg[%+v], err[%+v]", delMsg, ret.err)
case DeleteStatusUndo:
span.Warnf("delete message unconsume: msg[%+v]", delMsg)
default:
// do nothing
}
}
}

View File

@ -317,6 +317,8 @@ func (mgr *ShardRepairMgr) recordOneResult(ctx context.Context, r shardRepairRet
span.Warnf("unexpected result: msg[%+v], err[%+v]", r.repairMsg, r.err)
case ShardRepairStatusUndo:
span.Warnf("repair message unconsume: msg[%+v]", r.repairMsg)
default:
// do nothing
}
}

View File

@ -27,6 +27,10 @@ import (
var ms100 = 100 * time.Millisecond
var voidFunc = func(error) {
// do nothing
}
func TestRetryInsistBase(t *testing.T) {
var i int
cases := []struct {
@ -40,7 +44,7 @@ func TestRetryInsistBase(t *testing.T) {
{
exp: 0,
f: func() error { return nil },
on: func(error) {},
on: voidFunc,
d: ms100,
mind: 0,
maxd: ms100,
@ -54,7 +58,7 @@ func TestRetryInsistBase(t *testing.T) {
}
return nil
},
on: func(error) {},
on: voidFunc,
d: 5 * ms100,
mind: 10 * ms100,
maxd: 12 * ms100,
@ -68,7 +72,7 @@ func TestRetryInsistBase(t *testing.T) {
}
return nil
},
on: func(error) {},
on: voidFunc,
d: 5 * ms100,
mind: 5 * ms100,
maxd: 7 * ms100,
@ -116,7 +120,7 @@ func TestRetryInsistContext(t *testing.T) {
{
exp: 0,
f: func() error { return nil },
on: func(error) {},
on: voidFunc,
d: ms100,
mind: 0,
maxd: ms100,
@ -130,7 +134,7 @@ func TestRetryInsistContext(t *testing.T) {
}
return nil
},
on: func(error) {},
on: voidFunc,
d: 2 * ms100,
mind: 2 * ms100,
maxd: ctxDuration + ms100,
@ -144,7 +148,7 @@ func TestRetryInsistContext(t *testing.T) {
}
return nil
},
on: func(error) {},
on: voidFunc,
d: 5 * ms100,
mind: ctxDuration,
maxd: ctxDuration + ms100,

View File

@ -38,7 +38,9 @@ func TestTaskpoolBase(t *testing.T) {
runner.Run(func() {
time.Sleep(time.Second)
})
require.False(t, runner.TryRun(func() {}))
require.False(t, runner.TryRun(func() {
// do nothing
}))
runner.Close()
}

View File

@ -99,6 +99,8 @@ func (p *BlockCachePacket) GetOpMsg() (m string) {
m = "OpBlockCacheGet"
case OpBlockCacheDel:
m = "OpBlockCacheDel"
default:
// do nothing
}
return
}

View File

@ -101,6 +101,8 @@ func NewFile(s *Super, i *proto.InodeInfo, flag uint32, pino uint64, filename st
case syscall.O_RDWR:
fReader = blobstore.NewReader(clientConf)
fWriter = blobstore.NewWriter(clientConf)
default:
// no thing
}
log.LogDebugf("Trace NewFile:fReader(%v) fWriter(%v) ", fReader, fWriter)
return &File{super: s, info: i, fWriter: fWriter, fReader: fReader, parentIno: pino, name: filename}

View File

@ -99,6 +99,7 @@ func (c *ConsoleNode) writeError(err error, writer http.ResponseWriter) {
}
func (c ConsoleNode) Shutdown() {
// do nothing
}
func (c *ConsoleNode) Sync() {

View File

@ -193,6 +193,7 @@ func (si *ItemIterator) ApplyIndex() uint64 {
// Close Closes the iterator.
func (si *ItemIterator) Close() {
// do nothing
}
// Next returns the next item in the iterator.

View File

@ -89,6 +89,8 @@ func (dp *DataPartition) ApplyMemberChange(confChange *raftproto.ConfChange, ind
isUpdated, err = dp.removeRaftNode(req, index)
case raftproto.ConfUpdateNode:
log.LogDebugf("[updateRaftNode]: not support.")
default:
// do nothing
}
if err != nil {
log.LogErrorf("action[ApplyMemberChange] dp(%v) type(%v) err(%v).", dp.partitionID, confChange.Type, err)

View File

@ -276,7 +276,9 @@ func (s *LcScanner) scan() {
return
}
dentry := val.(*proto.ScanDentry)
job := func() {}
job := func() {
// do nothing
}
if s.dirChan.Len() > maxDirChanNum {
job = func() {
s.handleDirLimitDepthFirst(dentry)
@ -290,6 +292,8 @@ func (s *LcScanner) scan() {
if err != nil {
log.LogErrorf("handleDir failed, err(%v)", err)
}
default:
// do nothing
}
}

View File

@ -1515,4 +1515,6 @@ func (c *client) fileSize(ino uint64) (size int, gen uint64) {
return
}
func main() {}
func main() {
// do nothing
}

View File

@ -1621,6 +1621,8 @@ func sendOkReply(w http.ResponseWriter, r *http.Request, httpReply *proto.HTTPRe
dn := httpReply.Data.(*DataNode)
dn.RLock()
defer dn.RUnlock()
default:
// do nothing
}
reply, err := json.Marshal(httpReply)

View File

@ -647,6 +647,8 @@ func (m *Server) UidOperate(w http.ResponseWriter, r *http.Request) {
ok = vol.uidSpaceManager.removeUid(uid)
case util.AclListIP:
uidList = vol.uidSpaceManager.listAll()
default:
// do nothing
}
rsp := &proto.UidSpaceRsp{
@ -722,6 +724,8 @@ func (m *Server) aclOperate(w http.ResponseWriter, r *http.Request) {
sendErrReply(w, r, newErrHTTPReply(fmt.Errorf("inner error")))
return
}
default:
// do nothing
}
rsp := &proto.AclRsp{
@ -6220,6 +6224,8 @@ func (m *Server) S3QosGet(w http.ResponseWriter, r *http.Request) {
apiLimitConf[api].QPSQuota[uid] = v
case proto.ConcurrentLimit:
apiLimitConf[api].ConcurrentQuota[uid] = v
default:
// do nothing
}
return true
})

View File

@ -630,7 +630,7 @@ func (c *Cluster) scheduleToCheckHeartbeat() {
}()
}
func (c *Cluster) passAclCheck(ip string) {
// do nothing
}
func (c *Cluster) checkLeaderAddr() {

View File

@ -88,6 +88,8 @@ func (m *Server) handlePeerChange(confChange *proto.ConfChange) (err error) {
case proto.ConfRemoveNode:
m.raftStore.DeleteNode(confChange.Peer.ID)
msg = fmt.Sprintf("clusterID[%v] peerID:%v,nodeAddr[%v] has been removed", m.clusterName, confChange.Peer.ID, addr)
default:
// do nothing
}
Warn(m.clusterName, msg)
return

View File

@ -177,6 +177,7 @@ func (s *CarryWeightNodeSelector) getTotalMax(nodes *sync.Map) (total uint64) {
total = s.getTotalMaxForDataNodes(nodes)
case MetaNodeType:
total = s.getTotalMaxForMetaNodes(nodes)
default:
}
return
}
@ -617,8 +618,9 @@ func NewNodeSelector(name string, nodeType NodeType) NodeSelector {
return NewTicketNodeSelector(nodeType)
case AvailableSpaceFirstNodeSelectorName:
return NewAvailableSpaceFirstNodeSelector(nodeType)
default:
return NewCarryWeightNodeSelector(nodeType)
}
return NewCarryWeightNodeSelector(nodeType)
}
func (ns *nodeSet) getAvailMetaNodeHosts(excludeHosts []string, replicaNum int) (newHosts []string, peers []proto.Peer, err error) {

View File

@ -394,6 +394,7 @@ func NewNodesetSelector(name string, nodeType NodeType) NodesetSelector {
return NewTicketNodesetSelector(nodeType)
case AvailableSpaceFirstNodesetSelectorName:
return NewAvailableSpaceFirstNodesetSelector(nodeType)
default:
return NewRoundRobinNodesetSelector(nodeType)
}
return NewRoundRobinNodesetSelector(nodeType)
}

View File

@ -228,6 +228,8 @@ func createVol(kv map[string]interface{}, t *testing.T) {
checkWithDefault(kv, cacheCapacity, 80)
checkWithDefault(kv, replicaNumKey, 1)
break
default:
// do nothing
}
processWithFatalV2(proto.AdminCreateVol, true, kv, t)

View File

@ -443,6 +443,8 @@ func (mp *metaPartition) Apply(command []byte, index uint64) (resp interface{},
err = mp.fsmUniqCheckerEvict(req)
case opFSMVersionOp:
err = mp.fsmVersionOp(msg.V)
default:
// do nothing
}
return
@ -584,6 +586,8 @@ func (mp *metaPartition) ApplyMemberChange(confChange *raftproto.ConfChange, ind
updated, err = mp.confRemoveNode(req, index)
case raftproto.ConfUpdateNode:
//updated, err = mp.confUpdateNode(req, index)
default:
// do nothing
}
if err != nil {
return

View File

@ -127,6 +127,8 @@ func (mp *metaPartition) startSchedule(curIndex uint64) {
timer.Stop()
case opFSMStoreTick:
msgs = append(msgs, msg)
default:
// do nothing
}
case <-timer.C:
log.LogDebugf("[startSchedule] intervalToPersistData curIndex: %v,apply:%v", curIndex, mp.applyID)
@ -164,6 +166,8 @@ func (mp *metaPartition) startSchedule(curIndex uint64) {
}
lastCursor = curCursor
timerCursor.Reset(intervalToSyncCursor)
default:
// do nothing
}
}
}(mp.stopC)

View File

@ -171,6 +171,8 @@ func addGrants(acl *AccessControlPolicy, grants []grant, permission string) {
acl.AddGrant(g.value, TypeCanonicalUser, permission)
case "uri":
acl.AddGrant(g.value, TypeGroup, permission)
default:
// do nothing
}
}
}

View File

@ -152,9 +152,9 @@ func NewAuth(r *http.Request) (Auther, error) {
return NewQueryAuth(r)
case r.Method == http.MethodPost && strings.Contains(r.Header.Get(ContentType), ValueMultipartFormData):
return NewFormAuth(r)
default:
return nil, MissingSecurityElement
}
return nil, MissingSecurityElement
}
type Credential struct {

View File

@ -48,9 +48,9 @@ func NewFormAuth(r *http.Request) (Auther, error) {
auth.version = signatureV4
auth.algorithm = signV4Algorithm
return auth, auth.parseSignV4()
default:
return nil, MissingSecurityElement
}
return nil, MissingSecurityElement
}
// https://docs.aws.amazon.com/AmazonS3/latest/userguide/HTTPPOSTForms.html
@ -111,6 +111,8 @@ func (auth *FormAuth) parseSignV4() error {
return ErrMalformedXAmzDate
}
auth.credential.TimeStamp = val
default:
// do nothing
}
}

View File

@ -46,9 +46,9 @@ func NewHeaderAuth(r *http.Request) (Auther, error) {
auth.version = signatureV4
auth.algorithm = authFields[0]
return auth, auth.parseSignV4(authFields[1])
default:
return nil, ErrInvalidAuthHeader
}
return nil, ErrInvalidAuthHeader
}
// https://docs.aws.amazon.com/AmazonS3/latest/userguide/RESTAuthentication.html#ConstructingTheAuthenticationHeader
@ -188,8 +188,9 @@ func (auth *HeaderAuth) SignatureMatch(secretKey string, wildcards Wildcards) bo
signature = auth.buildSignatureV4(secretKey)
}
return auth.signature == signature
default:
return false
}
return false
}
func (auth *HeaderAuth) buildSignatureV2(secretKey string, wildcards Wildcards) string {

View File

@ -53,9 +53,9 @@ func NewQueryAuth(r *http.Request) (Auther, error) {
return auth, auth.parseSignV4()
}
return nil, ErrInvalidAuthQueryParams
default:
return nil, MissingSecurityElement
}
return nil, MissingSecurityElement
}
// https://docs.aws.amazon.com/AmazonS3/latest/userguide/RESTAuthentication.html#RESTAuthenticationQueryStringAuth
@ -77,6 +77,8 @@ func (auth *QueryAuth) parseSignV2() error {
auth.credential.Expires = expires
case Signature:
auth.signature = val
default:
// do nothing
}
}
@ -120,6 +122,8 @@ func (auth *QueryAuth) parseSignV4() error {
auth.credential.Request = cred[4]
case XAmzSignedHeaders:
auth.signedHeaders = strings.Split(val, ";")
default:
// do nothing
}
}
@ -143,8 +147,9 @@ func (auth *QueryAuth) IsExpired() bool {
ltime := ts.Add(-MaxRequestSkewedSeconds * time.Second)
rtime := ts.Add(time.Duration(auth.credential.Expires) * time.Second)
return !(now.After(ltime) && now.Before(rtime))
default:
return true
}
return true
}
func (auth *QueryAuth) IsSkewed() bool {
@ -185,8 +190,9 @@ func (auth *QueryAuth) SignatureMatch(secretKey string, wildcards Wildcards) boo
return auth.signature == auth.buildSignatureV2(secretKey, wildcards)
case signatureV4:
return auth.signature == auth.buildSignatureV4(secretKey)
default:
return false
}
return false
}
func (auth *QueryAuth) buildSignatureV2(secretKey string, wildcards Wildcards) string {

View File

@ -164,24 +164,34 @@ func (s *strictMetaLoader) loadPolicy() (p *Policy, err error) {
return s.v.loadBucketPolicy()
}
func (s *strictMetaLoader) storePolicy(p *Policy) {}
func (s *strictMetaLoader) storePolicy(p *Policy) {
// do nothing
}
func (s *strictMetaLoader) loadACL() (acp *AccessControlPolicy, err error) {
return s.v.loadBucketACL()
}
func (s *strictMetaLoader) storeACL(p *AccessControlPolicy) {}
func (s *strictMetaLoader) storeACL(p *AccessControlPolicy) {
// do nothing
}
func (s *strictMetaLoader) loadCORS() (cors *CORSConfiguration, err error) {
return s.v.loadBucketCors()
}
func (s *strictMetaLoader) storeCORS(cors *CORSConfiguration) {}
func (s *strictMetaLoader) storeCORS(cors *CORSConfiguration) {
// do nothing
}
func (s *strictMetaLoader) loadObjectLock() (o *ObjectLockConfig, err error) {
return s.v.loadObjectLock()
}
func (s *strictMetaLoader) storeObjectLock(cors *ObjectLockConfig) {}
func (s *strictMetaLoader) storeObjectLock(cors *ObjectLockConfig) {
// do nothing
}
func (s *strictMetaLoader) setSynced() {}
func (s *strictMetaLoader) setSynced() {
// do nothing
}

View File

@ -269,6 +269,8 @@ func (o *ObjectNode) policyCheck(f http.HandlerFunc) http.HandlerFunc {
case POLICY_UNKNOW:
// policy check result is unknown so that acl should be checked
log.LogWarnf("bucket policy check: policy unknown: requestID(%v) ", GetRequestID(r))
default:
// do nothing
}
}
@ -358,6 +360,8 @@ func (o *ObjectNode) allowedBySrcBucketPolicy(param *RequestParam, reqUid string
case POLICY_UNKNOW:
// policy check result is unknown so that acl should be checked
log.LogWarnf("srcBucket policy check: policy unknown: requestID(%v) ", GetRequestID(paramCopy.r))
default:
// do nothing
}
}

View File

@ -166,6 +166,8 @@ func (s *StatementV2) MatchAction(action string) bool {
return true
}
}
default:
// do nothing
}
return false
}
@ -181,6 +183,8 @@ func (s *StatementV2) MatchResource(bucket, key string) bool {
return true
}
}
default:
// do nothing
}
return false
}

View File

@ -76,9 +76,9 @@ func (v Value) MarshalJSON() ([]byte, error) {
return json.Marshal(v.i)
case reflect.Bool:
return json.Marshal(v.b)
default:
return nil, fmt.Errorf("unknown value kind %v", v.t)
}
return nil, fmt.Errorf("unknown value kind %v", v.t)
}
// stores bool value.
@ -105,9 +105,9 @@ func (v Value) String() string {
return strconv.Itoa(v.i)
case reflect.Bool:
return strconv.FormatBool(v.b)
default:
return ""
}
return ""
}
// decodes JSON data.

View File

@ -331,8 +331,9 @@ func policyCondMatch(op, input, val string) bool {
return input == val
case condStartsWith:
return strings.HasPrefix(input, val)
default:
return false
}
return false
}
func parseToInt64(val interface{}) (int64, error) {

View File

@ -902,8 +902,9 @@ func QosTypeString(factorType uint32) string {
return "FlowRead"
case FlowWriteType:
return "FlowWrite"
default:
return "unkown"
}
return "unkown"
}
type ClientLimitInfo struct {

View File

@ -463,6 +463,8 @@ func IsValidMsgReqType(serviceID string, msgType MsgType) (err error) {
if msgType|MsgAuthBase != 0 {
b = true
}
default:
// do nothing
}
if !b {
err = fmt.Errorf("invalid request type [%x] and serviceID[%s]", msgType, serviceID)

View File

@ -353,8 +353,9 @@ func (p *Packet) IsMasterCommand() bool {
proto.OpRemoveDataPartitionRaftMember,
proto.OpDataPartitionTryToLeader:
return true
default:
return false
}
return false
}
func (p *Packet) IsForwardPacket() bool {

View File

@ -582,6 +582,8 @@ func (n *node) iterate(dir direction, start, stop Item, includeStart bool, hit b
return hit, false
}
}
default:
// do nothing
}
return hit, true
}

View File

@ -5,6 +5,7 @@ import (
)
func init() {
// do nothing
}
func TestError01(t *testing.T) {

View File

@ -97,6 +97,8 @@ func setBlobLogLevel(loglevel Level) {
blevel = blog.Lwarn
case ErrorLevel:
blevel = blog.Lerror
default:
blevel = blog.Lwarn
}
blog.SetOutputLevel(blevel)
}

View File

@ -64,6 +64,8 @@ func GetMemInfo() (total, used uint64, err error) {
buffer = val * KB
case "Cached":
cached = val * KB
default:
// do nothing
}
}
used = total - free - buffer - cached

View File

@ -152,6 +152,8 @@ func (lw *LogWrite) backGroundWrite(umpType string) {
body = append(body, lw.bf.Bytes()...)
lw.bf.Reset()
AlarmPool.Put(alarm)
default:
// do nothing
}
if lw.backGroundCheckFile() != nil {
continue