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

[ASCII-2357]: Do not use %w when the error is nil #30092

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -53,7 +53,7 @@ func SetupInstaller(ctx context.Context) (err error) {
return fmt.Errorf("error creating dd-agent group: %w", err)
}
if addDDAgentUser(ctx) != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 thought: ‏ Shouldn't that be

Suggested change
if addDDAgentUser(ctx) != nil {
if err = addDDAgentUser(ctx); err != nil {
return fmt.Errorf("error creating dd-agent user: %w", err)
}

instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if addDDAgentUser(ctx) != nil {
if err = addDDAgentUser(ctx); err != nil {

Keeping track of the error would be good. (sorry for previous comments, I misread)

return fmt.Errorf("error creating dd-agent user: %w", err)
return fmt.Errorf("error creating dd-agent user")
}
err = exec.CommandContext(ctx, "usermod", "-g", "dd-agent", "dd-agent").Run()
if err != nil {
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
Loading