Fix a few static analysis findings (#11307)
This commit is contained in:
parent
bd0fefe47f
commit
de0253056c
|
@ -413,7 +413,7 @@ func (b *backend) upgrade(ctx context.Context, s logical.Storage) (bool, error)
|
|||
for _, roleName := range roleNames {
|
||||
// make sure the context hasn't been canceled
|
||||
if ctx.Err() != nil {
|
||||
return false, err
|
||||
return false, ctx.Err()
|
||||
}
|
||||
_, err := b.roleInternal(ctx, s, roleName)
|
||||
if err != nil {
|
||||
|
|
|
@ -112,12 +112,13 @@ type inflightRequest struct {
|
|||
|
||||
// remaining is the number of remaining inflight request that needs to
|
||||
// be processed before this object can be cleaned up
|
||||
remaining atomic.Uint64
|
||||
remaining *atomic.Uint64
|
||||
}
|
||||
|
||||
func newInflightRequest() *inflightRequest {
|
||||
return &inflightRequest{
|
||||
ch: make(chan struct{}),
|
||||
ch: make(chan struct{}),
|
||||
remaining: atomic.NewUint64(0),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -530,8 +530,8 @@ func looksLikeDuration(k string) bool {
|
|||
type SealStatusOutput struct {
|
||||
api.SealStatusResponse
|
||||
HAEnabled bool `json:"ha_enabled"`
|
||||
IsSelf bool `json:"is_self,omitempty""`
|
||||
ActiveTime time.Time `json:"active_time,omitempty""`
|
||||
IsSelf bool `json:"is_self,omitempty"`
|
||||
ActiveTime time.Time `json:"active_time,omitempty"`
|
||||
LeaderAddress string `json:"leader_address,omitempty"`
|
||||
LeaderClusterAddress string `json:"leader_cluster_address,omitempty"`
|
||||
PerfStandby bool `json:"performance_standby,omitempty"`
|
||||
|
|
|
@ -77,7 +77,7 @@ func (c *Client) DialLDAP(cfg *ConfigEntry) (Connection, error) {
|
|||
if err == nil {
|
||||
if retErr != nil {
|
||||
if c.Logger.IsDebug() {
|
||||
c.Logger.Debug("errors connecting to some hosts: %s", retErr.Error())
|
||||
c.Logger.Debug("errors connecting to some hosts", "error", retErr.Error())
|
||||
}
|
||||
}
|
||||
retErr = nil
|
||||
|
|
|
@ -42,9 +42,7 @@ func (s *StorageView) Get(ctx context.Context, key string) (*StorageEntry, error
|
|||
if entry == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if entry != nil {
|
||||
entry.Key = s.TruncateKey(entry.Key)
|
||||
}
|
||||
entry.Key = s.TruncateKey(entry.Key)
|
||||
|
||||
return &StorageEntry{
|
||||
Key: entry.Key,
|
||||
|
|
|
@ -48,9 +48,7 @@ func (v *View) Get(ctx context.Context, key string) (*Entry, error) {
|
|||
if entry == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if entry != nil {
|
||||
entry.Key = v.truncateKey(entry.Key)
|
||||
}
|
||||
entry.Key = v.truncateKey(entry.Key)
|
||||
|
||||
return &Entry{
|
||||
Key: entry.Key,
|
||||
|
|
|
@ -313,7 +313,7 @@ func (a *ActivityLog) saveCurrentSegmentToStorageLocked(ctx context.Context, for
|
|||
// Rotate to next segment
|
||||
a.currentSegment.entitySequenceNumber += 1
|
||||
if len(excessEntities) > activitySegmentEntityCapacity {
|
||||
a.logger.Warn("too many new active entities %v, dropping tail", len(excessEntities))
|
||||
a.logger.Warn("too many new active entities, dropping tail", "entities", len(excessEntities))
|
||||
excessEntities = excessEntities[:activitySegmentEntityCapacity]
|
||||
}
|
||||
a.currentSegment.currentEntities.Entities = excessEntities
|
||||
|
|
|
@ -569,6 +569,7 @@ func (i *IdentityStore) pathOIDCDeleteKey(ctx context.Context, req *logical.Requ
|
|||
// it is an error to delete a key that is actively referenced by a role
|
||||
roleNames, err := req.Storage.List(ctx, roleConfigPath)
|
||||
if err != nil {
|
||||
i.oidcLock.Unlock()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -577,10 +578,12 @@ func (i *IdentityStore) pathOIDCDeleteKey(ctx context.Context, req *logical.Requ
|
|||
for _, roleName := range roleNames {
|
||||
entry, err := req.Storage.Get(ctx, roleConfigPath+roleName)
|
||||
if err != nil {
|
||||
i.oidcLock.Unlock()
|
||||
return nil, err
|
||||
}
|
||||
if entry != nil {
|
||||
if err := entry.DecodeJSON(&role); err != nil {
|
||||
i.oidcLock.Unlock()
|
||||
return nil, err
|
||||
}
|
||||
if role.Key == targetKeyName {
|
||||
|
@ -599,6 +602,7 @@ func (i *IdentityStore) pathOIDCDeleteKey(ctx context.Context, req *logical.Requ
|
|||
// key can safely be deleted now
|
||||
err = req.Storage.Delete(ctx, namedKeyConfigPath+targetKeyName)
|
||||
if err != nil {
|
||||
i.oidcLock.Unlock()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ func (c *Client) DialLDAP(cfg *ConfigEntry) (Connection, error) {
|
|||
if err == nil {
|
||||
if retErr != nil {
|
||||
if c.Logger.IsDebug() {
|
||||
c.Logger.Debug("errors connecting to some hosts: %s", retErr.Error())
|
||||
c.Logger.Debug("errors connecting to some hosts", "error", retErr.Error())
|
||||
}
|
||||
}
|
||||
retErr = nil
|
||||
|
|
|
@ -42,9 +42,7 @@ func (s *StorageView) Get(ctx context.Context, key string) (*StorageEntry, error
|
|||
if entry == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if entry != nil {
|
||||
entry.Key = s.TruncateKey(entry.Key)
|
||||
}
|
||||
entry.Key = s.TruncateKey(entry.Key)
|
||||
|
||||
return &StorageEntry{
|
||||
Key: entry.Key,
|
||||
|
|
|
@ -48,9 +48,7 @@ func (v *View) Get(ctx context.Context, key string) (*Entry, error) {
|
|||
if entry == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if entry != nil {
|
||||
entry.Key = v.truncateKey(entry.Key)
|
||||
}
|
||||
entry.Key = v.truncateKey(entry.Key)
|
||||
|
||||
return &Entry{
|
||||
Key: entry.Key,
|
||||
|
|
Loading…
Reference in New Issue