github-vet / github-vet/rangeloop-pointer-findings

longhorn/longhorn-manager: upgrade/v102to110/upgrade.go; 21 LoC

Open
#11,607 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [longhorn/longhorn-manager](https://www.github.com/longhorn/longhorn-manager) at [upgrade/v102to110/upgrade.go](https://github.com/longhorn/longhorn-manager/blob/24300a52841e7f66b6568e05c327b2797df8abca/upgrade/v102to110/upgrade.go#L254-L274)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.

> reference to dp is reassigned at line 255

[Click here to see the code in its original context.](https://github.com/longhorn/longhorn-manager/blob/24300a52841e7f66b6568e05c327b2797df8abca/upgrade/v102to110/upgrade.go#L254-L274)

Click here to show the 21 line(s) of Go which triggered the analyzer.

```go
for _, dp := range deploymentList.Items {
dpp := &dp
needToUpdate, err := needToUpdateTolerationAnnotation(dpp)
if err != nil {
return err
}
if !needToUpdate {
continue
}
appliedTolerations := getNonDefaultTolerationList(dpp.Spec.Template.Spec.Tolerations)
appliedTolerationsByte, err := json.Marshal(appliedTolerations)
if err != nil {
return err
}
if err := util.SetAnnotation(dpp, types.GetLonghornLabelKey(types.LastAppliedTolerationAnnotationKeySuffix), string(appliedTolerationsByte)); err != nil {
return err
}
if _, err := kubeClient.AppsV1().Deployments(namespace).Update(dpp); err != nil {
return err
}
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: 24300a52841e7f66b6568e05c327b2797df8abca

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.