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 linter warnings #4

Merged
merged 3 commits into from
Jul 23, 2024
Merged

Fix linter warnings #4

merged 3 commits into from
Jul 23, 2024

Conversation

kolyshkin
Copy link
Owner

A few very simple linter warning fixes.


(Originally opened as syndtr#25).

@kolyshkin
Copy link
Owner Author

@avagin PTAL 🙏🏻

@ningmingxiao
Copy link

This branch is 9 commits ahead of @kolyshkin

status_path = fmt.Sprintf("/proc/%d/status", c.hdr.pid)
path := "/proc/self/status"
if c.hdr.pid != 0 {
path = "/proc/" + strconv.Itoa(int(c.hdr.pid)) + "/status"
Copy link

Choose a reason for hiding this comment

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

nit: I think Sprintf looks better for this case.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yep; fixed

@avagin
Copy link

avagin commented Jul 23, 2024

LGTM

Fix the following warning:

> capability_linux.go:407:17: S1039: unnecessary use of fmt.Sprintf (gosimple)
> 		status_path = fmt.Sprintf("/proc/self/status")
>		              ^

Also,
 - simplify the code for the common case when pid is 0;
 - rename a variable (to obey Go naming guidelines).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Fix the following linter warning:

> capability_linux.go:34:8: Error return value is not checked (errcheck)
> 	capget(&hdr, nil)
>	      ^

Here we deliberately ignore the error from capget() since we have no way
to report it, and hdr.ver will be 0 in case of an error anyway.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin merged commit c7166e4 into main Jul 23, 2024
@kolyshkin kolyshkin deleted the linter-warnings branch August 1, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants