github-vet / github-vet/rangeloop-pointer-findings
bosun-monitor/bosun: cmd/scollector/collectors/cpu_windows.go; 17 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [bosun-monitor/bosun](https://www.github.com/bosun-monitor/bosun) at [cmd/scollector/collectors/cpu_windows.go](https://github.com/bosun-monitor/bosun/blob/4ea808ab2ddfcd7dcc135372ea217aa17ef764cc/cmd/scollector/collectors/cpu_windows.go#L26-L42)
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 v is reassigned at line 28
[Click here to see the code in its original context.](https://github.com/bosun-monitor/bosun/blob/4ea808ab2ddfcd7dcc135372ea217aa17ef764cc/cmd/scollector/collectors/cpu_windows.go#L26-L42)
Click here to show the 17 line(s) of Go which triggered the analyzer.
```go
for _, v := range dst {
if v.Name == "_Total" {
winCPUTotalPerfOS = &v
continue
}
ts := TSys100NStoEpoch(v.Timestamp_Sys100NS)
tags := opentsdb.TagSet{"cpu": v.Name}
num++
//Divide by 1e5 because: 1 seconds / 100 Nanoseconds = 1e7. This is the percent time as a decimal, so divide by two less zeros to make it the same as the result * 100.
used += (v.PercentUserTime + v.PercentPrivilegedTime + v.PercentInterruptTime) / 1e5
AddTS(&md, winCPU, ts, v.PercentPrivilegedTime/1e5, opentsdb.TagSet{"type": "privileged"}.Merge(tags), metadata.Counter, metadata.Pct, descWinCPUPrivileged)
AddTS(&md, winCPU, ts, v.PercentInterruptTime/1e5, opentsdb.TagSet{"type": "interrupt"}.Merge(tags), metadata.Counter, metadata.Pct, descWinCPUInterrupt)
AddTS(&md, winCPU, ts, v.PercentUserTime/1e5, opentsdb.TagSet{"type": "user"}.Merge(tags), metadata.Counter, metadata.Pct, descWinCPUUser)
AddTS(&md, winCPU, ts, v.PercentIdleTime/1e5, opentsdb.TagSet{"type": "idle"}.Merge(tags), metadata.Counter, metadata.Pct, descWinCPUIdle)
AddTS(&md, "win.cpu.interrupts", ts, v.InterruptsPersec, tags, metadata.Counter, metadata.Event, descWinCPUInterrupts)
Add(&md, "win.cpu.dpcs", v.DPCRate, tags, metadata.Gauge, metadata.Event, descWinCPUDPC)
}
```
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: 4ea808ab2ddfcd7dcc135372ea217aa17ef764cc
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.