github-vet / github-vet/rangeloop-pointer-findings
a2geek/bosh-lxd-cpi-release: src/github.com/lxc/lxd/lxd/container.go; 37 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [a2geek/bosh-lxd-cpi-release](https://www.github.com/a2geek/bosh-lxd-cpi-release) at [src/github.com/lxc/lxd/lxd/container.go](https://github.com/a2geek/bosh-lxd-cpi-release/blob/e28a247be3960d74b9c7a305428ee88356b73773/src/github.com/lxc/lxd/lxd/container.go#L1618-L1654)
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 c used in defer or goroutine at line 1621
[Click here to see the code in its original context.](https://github.com/a2geek/bosh-lxd-cpi-release/blob/e28a247be3960d74b9c7a305428ee88356b73773/src/github.com/lxc/lxd/lxd/container.go#L1618-L1654)
Click here to show the 37 line(s) of Go which triggered the analyzer.
```go
for _, c := range containers {
ch := make(chan error)
go func() {
snapshotName, err := containerDetermineNextSnapshotName(d, c, "snap%d")
if err != nil {
logger.Error("Error retrieving next snapshot name", log.Ctx{"err": err, "container": c})
ch <- nil
return
}
snapshotName = fmt.Sprintf("%s%s%s", c.Name(), shared.SnapshotDelimiter, snapshotName)
args := db.ContainerArgs{
Architecture: c.Architecture(),
Config: c.LocalConfig(),
Ctype: db.CTypeSnapshot,
Devices: c.LocalDevices(),
Ephemeral: c.IsEphemeral(),
Name: snapshotName,
Profiles: c.Profiles(),
Project: c.Project(),
Stateful: false,
}
_, err = containerCreateAsSnapshot(d.State(), args, c)
if err != nil {
logger.Error("Error creating snapshots", log.Ctx{"err": err, "container": c})
}
ch <- nil
}()
select {
case <-ctx.Done():
return nil
case <-ch:
}
}
```
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: e28a247be3960d74b9c7a305428ee88356b73773
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.