-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Errcheck linting fixes #2781
Errcheck linting fixes #2781
Conversation
@@ -175,19 +175,19 @@ func (t *tty) ClosePostStart() error { | |||
func (t *tty) Close() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this function never returns an error; wondering if it should either not have the error return, or if one (or more) of the errors should actually be returned (or a multi-error used)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently no callers of this care about the error, so I'd make it not return anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having Close()
return an error is mostly so that you can map it to io.Closer
as well as being "good Go practice". I think there is actually a bug here that we aren't returning Close()
errors from any of the Close
s we call in the function, but since very few projects check Close()
errors I guess it isn't that bad... 🤷♂️
@kolyshkin @AkihiroSuda ptal |
fHook.Run(state) | ||
err := fHook.Run(state) | ||
if err != nil { | ||
t.Fatal(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not important, but the code used to keep checking other cases even after one of them failed, and now it's not.
Fine either way for me, just noticing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... but there's only a single check in this test, and if that would fail it would already fail the test.
I think it's correct with this change, so I'll keep it, but feel free to comment if I overlooked something 😅
Mostly LGTM; left some nits. |
Overall, I don't think we should try to make master CI green again before rc93, so I'd rather have this one merged after the release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main comment is that I'm not sure defer func() { _ = ... }()
is worth the annoyance over // nolint
-- especially since I'm pretty sure it captures variables differently to a naked defer
.
libcontainer/container_linux.go
Outdated
@@ -1299,7 +1299,7 @@ func (c *linuxContainer) Restore(process *Process, criuOpts *CriuOpts) error { | |||
if err != nil { | |||
return err | |||
} | |||
defer unix.Unmount(root, unix.MNT_DETACH) | |||
defer func() { _ = unix.Unmount(root, unix.MNT_DETACH) }() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the defer funcWhichReturnsErr()
cases I would go with // nolint
because the alternative is quite a bit uglier (and I think in some cases may have strange behaviour with variable values -- because IIRC closures capture variables slightly differently to defer
statements).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about suggesting something like that, too. Having to add a whole function call to satisfy a linter is borderline overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed those to use //nolint: errcheck
06d41c8
to
8f47285
Compare
8f47285
to
ae3291c
Compare
ae3291c
to
ded8a28
Compare
rebased |
@cyphar @kolyshkin ptal |
ded8a28
to
9e05d0a
Compare
Needs rebase |
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
rebased 👍 |
@kolyshkin @cyphar PTAL, v1.0.0 should be released with green CI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though we should probably also enable the golint tests for PRs if it's green now.
Seems that this didn't fix all the lints:
I'll send a PR to fix these today. |
Split it to to smaller commit for easier review, but happy to squash if wanted
addresses part of #2627