github-vet / github-vet/rangeloop-pointer-findings
formicidae-tracker/zeus: zeus/run.go; 68 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [formicidae-tracker/zeus](https://www.github.com/formicidae-tracker/zeus) at [zeus/run.go](https://github.com/formicidae-tracker/zeus/blob/dc674df98f3f93fb2d8b66ca3189f4a16b56acac/zeus/run.go#L79-L146)
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.
> range-loop variable zname used in defer or goroutine at line 129
[Click here to see the code in its original context.](https://github.com/formicidae-tracker/zeus/blob/dc674df98f3f93fb2d8b66ca3189f4a16b56acac/zeus/run.go#L79-L146)
Click here to show the 68 line(s) of Go which triggered the analyzer.
```go
for zname, z := range c.Zones {
logger := log.New(os.Stderr, "[zone/"+zname+"]: ", log.LstdFlags)
logger.Printf("Loading zone")
m, ok := managers[z.CANInterface]
if ok == false {
var err error
logger.Printf("Opening interface '%s'", z.CANInterface)
intf, err := socketcan.NewRawInterface(z.CANInterface)
if err != nil {
return err
}
m = NewBusManager(z.CANInterface, intf, zeus.HeartBeatPeriod)
managers[z.CANInterface] = m
}
var stateReports chan<- zeus.StateReport = nil
reporters := []ClimateReporter{}
if cmd.NoAvahi == false {
rpc[zname], err = NewRPCReporter(zname, olympusHost, z, os.Stderr)
if err != nil {
return err
}
reporters = append(reporters, rpc[zname])
stateReports = rpc[zname].StateChannel()
wgRpc.Add(1)
go rpc[zname].Report(wgRpc)
}
capabilities, err := ComputeZoneRequirements(&z, reporters)
if err != nil {
return err
}
allCapabilities = append(allCapabilities, capabilities...)
interpolers[zname], err = NewInterpolationManager(zname, z.States, z.Transitions, capabilities, stateReports, os.Stderr)
if err != nil {
return err
}
alarmMonitors[zname], err = NewAlarmMonitor(zname)
if err != nil {
return err
}
go alarmMonitors[zname].Monitor()
if cmd.NoAvahi == false {
go func() {
for ae := range alarmMonitors[zname].Outbound() {
rpc[zname].AlarmChannel() <- ae
}
close(rpc[zname].AlarmChannel())
}()
} else {
go func() {
logger := log.New(os.Stderr, "[zone/"+zname+"/alarm]: ", log.LstdFlags)
for ae := range alarmMonitors[zname].Outbound() {
logger.Printf("%+v", ae)
}
}()
}
m.AssignCapabilitiesForID(arke.NodeID(z.DevicesID), capabilities, alarmMonitors[zname].Inbound())
wgInterpolation.Add(1)
go interpolers[zname].Interpolate(wgInterpolation, init, quit)
}
```
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: dc674df98f3f93fb2d8b66ca3189f4a16b56acac
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.