Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few static analysis findings #11307

Merged
merged 1 commit into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion builtin/credential/aws/path_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions command/agent/cache/lease_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand Down
4 changes: 2 additions & 2 deletions command/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion sdk/helper/ldaputil/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions sdk/logical/storage_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions sdk/physical/physical_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion vault/activity_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions vault/identity_store_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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 {
Expand All @@ -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
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.