Skip to content

Commit

Permalink
[ASCII-2357]: Do not use %w when the error is nil (#30092)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogaca-dd authored Oct 24, 2024
1 parent 3845925 commit a5b503f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/security-agent/subcommands/runtime/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func dumpNetworkNamespace(_ log.Component, _ config.Component, _ secrets.Compone
}

if len(resp.GetError()) > 0 {
return fmt.Errorf("couldn't dump network namespaces: %w", err)
return fmt.Errorf("couldn't dump network namespaces: %s", resp.GetError())
}

fmt.Printf("Network namespace dump: %s\n", resp.GetDumpFilename())
Expand Down
2 changes: 1 addition & 1 deletion cmd/system-probe/subcommands/runtime/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func dumpNetworkNamespace(_ log.Component, _ config.Component, _ secrets.Compone
}

if len(resp.GetError()) > 0 {
return fmt.Errorf("couldn't dump network namespaces: %w", err)
return fmt.Errorf("couldn't dump network namespaces: %s", resp.GetError())
}

fmt.Printf("Network namespace dump: %s\n", resp.GetDumpFilename())
Expand Down
2 changes: 1 addition & 1 deletion pkg/ebpf/bytecode/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func VerifyAssetPermissions(assetPath string) error {
}
stat, ok := info.Sys().(*syscall.Stat_t)
if !ok {
return fmt.Errorf("error getting permissions for output file %s: %w", assetPath, err)
return fmt.Errorf("error getting permissions for output file %s", assetPath)
}
if stat.Uid != 0 || stat.Gid != 0 || info.Mode().Perm()&os.FileMode(0022) != 0 {
return fmt.Errorf("%s has incorrect permissions: user=%v, group=%v, permissions=%v", assetPath, stat.Uid, stat.Gid, info.Mode().Perm())
Expand Down
2 changes: 1 addition & 1 deletion pkg/fleet/installer/service/datadog_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func SetupInstaller(ctx context.Context) (err error) {
if err = addDDAgentGroup(ctx); err != nil {
return fmt.Errorf("error creating dd-agent group: %w", err)
}
if addDDAgentUser(ctx) != nil {
if err = addDDAgentUser(ctx); err != nil {
return fmt.Errorf("error creating dd-agent user: %w", err)
}
err = exec.CommandContext(ctx, "usermod", "-g", "dd-agent", "dd-agent").Run()
Expand Down
2 changes: 1 addition & 1 deletion pkg/security/probe/monitors/runtime/runtime_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (m *Monitor) sendCgroupMetrics() error {
}
}
if len(memoryCgroup.Path) == 0 {
return fmt.Errorf("couldn't find memory controller in: %v: %w", cgroups, err)
return fmt.Errorf("couldn't find memory controller in: %v", cgroups)
}

usageInBytes, err := utils.ParseCgroupFileValue("memory", memoryCgroup.Path, "memory.usage_in_bytes")
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/containers/metrics/system/collector_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (c *systemCollector) GetContainerIDForInode(inode uint64, cacheValidity tim

cg = c.reader.GetCgroupByInode(inode)
if cg == nil {
return "", fmt.Errorf("containerID not found from inode %d, err: %w", inode, err)
return "", fmt.Errorf("containerID not found from inode %d", inode)
}
}

Expand Down

0 comments on commit a5b503f

Please sign in to comment.