Skip to content

Conversation

Fedosin
Copy link
Contributor

@Fedosin Fedosin commented Jun 6, 2023

What this PR does / why we need it:

This PR enables additional linters and removes unused (commented) ones. All issues reported by linters are resolved either with "make lint-fix" or manually.

Noticeably, we fix implicit memory aliasing in for loops. In golang the iteration variable is reused. At each iteration, the value of the next element in the range expression is assigned to the iteration variable; "provider" doesn't change, only its value changes. Hence, the expression &provider is referring to the same location in memory.

The recommended solution for the issue is to redeclare "provider" inside the for loop.

For more information: golang/go#56010

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 6, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 6, 2023
Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

Thanks for improvement, overall looks good, 2 questions inline:

Fedosin added 2 commits June 7, 2023 12:13
This commit enables additional linters and removes unused (commented) ones.

All issues reported by linters are resolved either with "make lint-fix" or
manually.
In golang the iteration variable is reused. At each iteration, the value
of the next element in the range expression is assigned to the iteration
variable; "provider" doesn't change, only its value changes. Hence, the
expression &provider is referring to the same location in memory.

The recommended solution for the issue is to redeclare "provider" inside
the for loop.

For more information:
golang/go#56010
https://husni.dev/beware-of-implicit-memory-aliasing-in-go-foor-loop/
Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

This is a nice cleanup, thank you @Fedosin

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 7, 2023
Copy link
Contributor

@alexander-demicev alexander-demicev left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexander-demicev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 7, 2023
@k8s-ci-robot k8s-ci-robot merged commit 840a54e into kubernetes-sigs:main Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants