github-vet / github-vet/rangeloop-pointer-findings
gravitational/robotest: infra/gravity/provision.go; 26 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [gravitational/robotest](https://www.github.com/gravitational/robotest) at [infra/gravity/provision.go](https://github.com/gravitational/robotest/blob/3774f8641439b19c4e0e598db8f87c52ea0e4817/infra/gravity/provision.go#L510-L535)
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 path used in defer or goroutine at line 514
[Click here to see the code in its original context.](https://github.com/gravitational/robotest/blob/3774f8641439b19c4e0e598db8f87c52ea0e4817/infra/gravity/provision.go#L510-L535)
Click here to show the 26 line(s) of Go which triggered the analyzer.
```go
for _, path := range paths {
if !strings.HasPrefix(path, "/dev") {
defer func() {
errRemove := sshutil.Run(ctx, node.Client(), node.Logger(),
fmt.Sprintf("sudo /bin/rm -f %s", path), nil)
if errRemove != nil {
logger.Warnf("Failed to remove path: %v.", errRemove)
}
}()
}
var out string
err := sshutil.RunAndParse(ctx, node.Client(), node.Logger(),
fmt.Sprintf("sudo dd if=/dev/zero of=%s bs=100K count=1024 conv=fdatasync 2>&1", path),
nil, sshutil.ParseAsString(&out))
if err != nil {
return wait.Abort(trace.Wrap(err))
}
speed, err := ParseDDOutput(out)
if err != nil {
return wait.Abort(trace.Wrap(err))
}
if speed < minSpeed {
return wait.Continue("%s has %v/s < minimum of %v/s",
path, humanize.Bytes(speed), humanize.Bytes(minSpeed))
}
}
```
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: 3774f8641439b19c4e0e598db8f87c52ea0e4817
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.