github-vet / github-vet/rangeloop-pointer-findings
pydio/cells: common/utils/filesystem/filesystem_windows.go; 26 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [pydio/cells](https://www.github.com/pydio/cells) at [common/utils/filesystem/filesystem_windows.go](https://github.com/pydio/cells/blob/6dc9e74ee06d7508dc270107bc6f7eae74bdbe20/common/utils/filesystem/filesystem_windows.go#L74-L99)
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 drive used in defer or goroutine at line 76
[Click here to see the code in its original context.](https://github.com/pydio/cells/blob/6dc9e74ee06d7508dc270107bc6f7eae74bdbe20/common/utils/filesystem/filesystem_windows.go#L74-L99)
Click here to show the 26 line(s) of Go which triggered the analyzer.
```go
for _, drive := range "ABCDEFGHIJKLMNOPQRSTUVWXYZ" {
go func() {
driveLetter := string(drive) + ":"
_, err := os.Open(driveLetter)
if err == nil {
doneChan <- ""
}
}()
select {
case <-doneChan:
c := h.MustFindProc("GetDiskFreeSpaceExW")
var freeBytes uint64
rootDrive := string(drive) + ":"
_, _, _ = c.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(rootDrive))), uintptr(unsafe.Pointer(&freeBytes)), 0, 0)
log.Logger(ctx).Info("detected volume " + strings.ToUpper(string(drive)))
volumes = append(volumes, &tree.Node{
Path: fmt.Sprintf("%c:/", drive),
Size: int64(freeBytes),
Type: tree.NodeType_COLLECTION,
Uuid: fmt.Sprintf("%c-drive", drive),
})
case <-time.After(time.Millisecond * 10):
}
}
```
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: 6dc9e74ee06d7508dc270107bc6f7eae74bdbe20
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.