github-vet / github-vet/rangeloop-pointer-findings
cnrancher/octopus: adaptors/mqtt/pkg/physical/device.go; 18 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [cnrancher/octopus](https://www.github.com/cnrancher/octopus) at [adaptors/mqtt/pkg/physical/device.go](https://github.com/cnrancher/octopus/blob/3793775c1da67af923abfe79660e9d8055b262b3/adaptors/mqtt/pkg/physical/device.go#L303-L320)
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 newSpecProp was used in a composite literal at line 309
[Click here to see the code in its original context.](https://github.com/cnrancher/octopus/blob/3793775c1da67af923abfe79660e9d8055b262b3/adaptors/mqtt/pkg/physical/device.go#L303-L320)
Click here to show the 18 line(s) of Go which triggered the analyzer.
```go
for _, newSpecProp := range newSpecProps {
if newSpecProp.ReadOnly != nil && !*newSpecProp.ReadOnly {
var staleSpecProp = staleSpecPropsIndex[newSpecProp.Name]
// publishes again if changed
if !reflect.DeepEqual(staleSpecProp, newSpecProp) {
var err = d.mqttClient.Publish(mqtt.PublishMessage{
Render: getPublishRender(&newSpecProp),
QoSPointer: (*byte)(newSpecProp.QoS),
RetainedPointer: newSpecProp.Retained,
Payload: newSpecProp.Value,
})
if err != nil {
return errors.Wrapf(err, "failed to publish property %s", newSpecProp.Name)
}
d.log.V(4).Info("Sent payload", "type", "AttributedTopic", "property", newSpecProp.Name)
}
}
}
```
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: 3793775c1da67af923abfe79660e9d8055b262b3
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.