github-vet / github-vet/rangeloop-pointer-findings
e154/smart-home: endpoint/flow.go; 46 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [e154/smart-home](https://www.github.com/e154/smart-home) at [endpoint/flow.go](https://github.com/e154/smart-home/blob/08bfcca81c321b893cad87842a4ea40713f62e09/endpoint/flow.go#L219-L264)
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 which takes a reference to element at line 222 may start a goroutine
[Click here to see the code in its original context.](https://github.com/e154/smart-home/blob/08bfcca81c321b893cad87842a4ea40713f62e09/endpoint/flow.go#L219-L264)
Click here to show the 46 line(s) of Go which triggered the analyzer.
```go
for _, element := range params.Objects {
fl := &m.FlowElement{}
common.Copy(&fl, &element)
common.Copy(&fl.GraphSettings.Position, &element.Position)
fl.Uuid.Scan(element.Id)
fl.FlowId = newFlow.Id
fl.Name = element.Title
if element.FlowLink != nil && element.FlowLink.Id != 0 {
fl.FlowLink = &element.FlowLink.Id
}
if element.Script != nil {
fl.ScriptId = &element.Script.Id
}
switch element.Type.Name {
case "event":
if element.Type.Start != nil {
fl.PrototypeType = common.FlowElementsPrototypeMessageHandler
} else if element.Type.End != nil {
fl.PrototypeType = common.FlowElementsPrototypeMessageEmitter
}
case "task":
fl.PrototypeType = common.FlowElementsPrototypeTask
case "gateway":
fl.PrototypeType = common.FlowElementsPrototypeGateway
case "flow":
fl.PrototypeType = common.FlowElementsPrototypeFlow
default:
fl.PrototypeType = common.FlowElementsPrototypeDefault
}
_, errs = fl.Valid()
if len(errs) > 0 {
for _, err := range errs {
log.Errorf("%s %s", err.Key, err.Message)
}
return
}
if err = tx.FlowElement.AddOrUpdateFlowElement(fl); err != nil {
return
}
}
```
Click here to show extra information the analyzer produced.
```
The following paths through the callgraph could lead to a goroutine:
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2) -> (mqttNewMessage, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2) -> (start, 0)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (updateMetric, 0) -> (Update, 1) -> (update, 1) -> (updateClientState, 1) -> (StartAndGC, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (updateMetric, 0) -> (Update, 1) -> (update, 1) -> (updateClientState, 1) -> (Load, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (updateMetric, 0) -> (Update, 1) -> (update, 1) -> (updateClientState, 1) -> (Broadcast, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2) -> (Load, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2) -> (StartAndGC, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (updateMetric, 0) -> (Update, 1) -> (update, 1) -> (updateClientState, 1) -> (Load, 1) -> (panic, 1) -> (collectClientStats, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (updateMetric, 0)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (updateMetric, 0) -> (Update, 1) -> (update, 1) -> (updateClientState, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2) -> (sendMessageDelivery, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2) -> (AddWorker, 1) -> (AddAction, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2) -> (Load, 1) -> (HandlerFor, 2) -> (collectClientStats, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (updateMetric, 0) -> (Update, 1) -> (update, 1) -> (updateClientState, 1) -> (Execute, 1) -> (DoFull, 0) -> (Do, 0) -> (doAction, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2) -> (Broadcast, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (updateMetric, 0) -> (Update, 1) -> (update, 1) -> (updateClientState, 1) -> (NewCache, 2) -> (StartAndGC, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2) -> (collect, 0) -> (collectClientStats, 1)
(Copy, 2) -> (File, 2) -> (Close, 0) -> (FormatCloseMessage, 2) -> (Add, 1) -> (uint8, 1) -> (GetModel, 0) -> (List, 2) -> (Execute, 1) -> (DoFull, 0) -> (Do, 0) -> (doAction, 1)
```
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: 08bfcca81c321b893cad87842a4ea40713f62e09
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.