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

Add more go vet checks #1849

Merged
merged 2 commits into from
Aug 17, 2023
Merged

Add more go vet checks #1849

merged 2 commits into from
Aug 17, 2023

Conversation

helsaawy
Copy link
Contributor

Turn on all go vet checks (except for fieldalignment and ignore shadowing err variables.

Caught a couple minor bugs:

  • ncproxy did not set the panic file for the service
  • nil-field access in logs
  • not updating processorLimits in (*UtilityVM).Update

Simplified a couple if statements clauses where conditional evaluation made != nil checks redundant.

@helsaawy helsaawy requested a review from a team as a code owner July 26, 2023 17:33
@@ -250,7 +250,7 @@ func (s *service) teardownConfigureContainerNetworking(ctx context.Context, req

for _, endpoint := range resp.Endpoints {
if endpoint == nil {
log.G(ctx).WithField("name", endpoint.ID).Warn("failed to find endpoint to delete")
log.G(ctx).Warn("failed to find endpoint to delete")
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, is it possible to receive nil endpoints in a valid response from ncproxy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not too sure, but I think absent a guarantee of such, the nil-check and logging is probably worth keeping.
@katiewasnothere, thought?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's possible but also this is just a test tool so I don't think we need to worry too much either way.

Copy link
Contributor

@ambarve ambarve left a comment

Choose a reason for hiding this comment

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

Minor suggestions/questions but LGTM!

Turn on all [go vet](https://pkg.go.dev/cmd/vet) checks (except for
`fieldalignment`, and ignore shadowing `err` variables.

Caught a couple minor bugs:
 - ncproxy did not set the panic file for the service
 - `nil`-field access in logs
 - not updating `processorLimits` in `(*UtilityVM).Update`

Simplified a couple `if` statements clauses where
[conditional evaluation](https://go.dev/ref/spec#Logical_operators)
made `!= nil` checks redundant.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
@helsaawy helsaawy merged commit 5751c1b into microsoft:main Aug 17, 2023
16 checks passed
@helsaawy helsaawy deleted the go-vet branch August 17, 2023 21:45
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 29, 2024
* Enable all go vet checks

Turn on all [go vet](https://pkg.go.dev/cmd/vet) checks (except for
`fieldalignment`, and ignore shadowing `err` variables.

Caught a couple minor bugs:
 - ncproxy did not set the panic file for the service
 - `nil`-field access in logs
 - not updating `processorLimits` in `(*UtilityVM).Update`

Simplified a couple `if` statements clauses where
[conditional evaluation](https://go.dev/ref/spec#Logical_operators)
made `!= nil` checks redundant.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>

* PR: err name; decl

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>

---------

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
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