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

projectcalico/cni-plugin: pkg/plugin/plugin.go; 21 LoC

Open
#17,760 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 [projectcalico/cni-plugin](https://www.github.com/projectcalico/cni-plugin) at [pkg/plugin/plugin.go](https://github.com/projectcalico/cni-plugin/blob/61de8217d21637a9b556193cc4ff7a2e746d78cf/pkg/plugin/plugin.go#L243-L263)

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 ep is reassigned at line 255

[Click here to see the code in its original context.](https://github.com/projectcalico/cni-plugin/blob/61de8217d21637a9b556193cc4ff7a2e746d78cf/pkg/plugin/plugin.go#L243-L263)

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

```go
for _, ep := range endpoints.Items {
var match bool
match, err = wepIDs.WorkloadEndpointIdentifiers.NameMatches(ep.Name)
if err != nil {
// We should never hit this error, because it should have already been
// caught by CalculateWorkloadEndpointName.
err = fmt.Errorf("invalid WorkloadEndpoint identifiers: %v", wepIDs.WorkloadEndpointIdentifiers)
return
}

if match {
logger.Debugf("Found a match for WorkloadEndpoint: %v", ep)
endpoint = &ep
// Assign the WEP name to wepIDs' WEPName field.
wepIDs.WEPName = endpoint.Name
// Put the endpoint name from the matched WEP in the identifiers.
wepIDs.Endpoint = ep.Spec.Endpoint
logger.Infof("Calico CNI found existing endpoint: %v", endpoint)
break
}
}

```

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: 61de8217d21637a9b556193cc4ff7a2e746d78cf

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.