github-vet / github-vet/rangeloop-pointer-findings
galenliu/yeelight-adapter: main.go; 40 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [galenliu/yeelight-adapter](https://www.github.com/galenliu/yeelight-adapter) at [main.go](https://github.com/galenliu/yeelight-adapter/blob/7349ae984da27bd965abd3b5b5ab8a98ed6587d9/main.go#L102-L141)
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.
> function call at line 103 may store a reference to light
[Click here to see the code in its original context.](https://github.com/galenliu/yeelight-adapter/blob/7349ae984da27bd965abd3b5b5ab8a98ed6587d9/main.go#L102-L141)
Click here to show the 40 line(s) of Go which triggered the analyzer.
```go
for _, light := range lights {
var yeeLight = NewYeeLightDevice(addon.NewDevice(adapter, light.ID), &light)
yeeLight.AppendType("Light")
prop := addon.NewColorModeProperty(ColorModel, light.ColorMode-1)
var p = NewYeeLightProperty(prop, yeeLight)
yeeLight.AddProperty(p)
for _, prop := range light.Support {
switch prop {
case "set_power":
proxyProp := addon.NewOnOffProperty(On)
var _p = NewYeeLightProperty(proxyProp, yeeLight)
yeeLight.AddProperty(_p)
_p.SetValue(true)
case "set_bright":
p := addon.NewBrightnessProperty(Brightness, 0, 100)
var _p = NewYeeLightProperty(p, yeeLight)
_p.SetValue(10)
yeeLight.AddProperty(_p)
case "set_rgb":
p := addon.NewColorProperty(ColorTemperature)
var _p = NewYeeLightProperty(p, yeeLight)
yeeLight.AddProperty(_p)
_p.SetValue("#FF0000")
yeeLight.AddProperty(_p)
case "set_ct_abx":
p := addon.NewColorTemperatureProperty(ColorTemperature, 170000, 680000)
var _p = NewYeeLightProperty(p, yeeLight)
_p.SetValue(680000)
yeeLight.AddProperty(_p)
default:
continue
}
}
YeeLights = append(YeeLights, yeeLight)
}
```
Click here to show extra information the analyzer produced.
```
The following graphviz dot graph describes paths through the callgraph that could lead to a function which writes a pointer argument:
digraph G {
"(NewYeeLightDevice, 2)" -> {}
}
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
```
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: 7349ae984da27bd965abd3b5b5ab8a98ed6587d9
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.