github-vet / github-vet/rangeloop-pointer-findings
back0893/nb: router/Handler.go; 49 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [back0893/nb](https://www.github.com/back0893/nb) at [router/Handler.go](https://github.com/back0893/nb/blob/f054f73aa6974c66861e850a3cba9b9024cec35e/router/Handler.go#L52-L100)
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.
>
[Click here to see the code in its original context.](https://github.com/back0893/nb/blob/f054f73aa6974c66861e850a3cba9b9024cec35e/router/Handler.go#L52-L100)
Click here to show the 49 line(s) of Go which triggered the analyzer.
```go
for _, pin := range pins {
utils.LoggerObject.Write(pin.Time.Format("2006-01-02T15:04:05"))
if pin.PinId == 1 {
//开关输入1
val, err := strconv.Atoi(msg.Switch1[1:])
if err != nil {
continue
}
pin.PinValue = val
} else if pin.PinId == 2 {
//开关输入2
val, err := strconv.Atoi(msg.Switch2[1:])
if err != nil {
continue
}
pin.PinValue = val
} else if pin.PinId == 3 {
//开关输入3
val, err := strconv.Atoi(msg.Input1[1:])
if err != nil {
continue
}
pin.PinValue = val
pin.Unit = "mV"
} else if pin.PinId == 4 {
//开关输入4
val, err := strconv.Atoi(msg.Input2[1:])
if err != nil {
continue
}
pin.PinValue = val
pin.Unit = "mV"
}
pin.Time = datetime
//保存至全局变量中
db.Save(&pin)
//再去插入value中的历史数据
node_value := model.AutoNodeValue{}
node_value.Time = pin.Time
node_value.NodeId = int(node.ID)
node_value.Type = pin.Type
node_value.Value = pin.PinValue
node_value.Pin = int(pin.ID)
//对于开关量有一个额外的alarm参数
if pin.Type == 0 {
node_value.Alarm = node_value.Value
}
db.Create(&node_value)
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature {Save 1} was not found in the callgraph; reference was passed directly 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: f054f73aa6974c66861e850a3cba9b9024cec35e
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.