fix PR review

Signed-off-by: Dani Louca <dlouca@splunk.com>
pull/1534/head
Dani Louca 2 years ago
parent 311c16dbaf
commit 1d0f16a4cb
No known key found for this signature in database
GPG Key ID: 98E9BF10CD93B600

@ -19,8 +19,10 @@ import (
"github.com/shirou/gopsutil/v4/internal/common"
)
const volumeNameBufferLength = uint32(windows.MAX_PATH + 1)
const volumePathBufferLength = volumeNameBufferLength
const (
volumeNameBufferLength = uint32(windows.MAX_PATH + 1)
volumePathBufferLength = volumeNameBufferLength
)
var (
procGetDiskFreeSpaceExW = common.Modkernel32.NewProc("GetDiskFreeSpaceExW")
@ -165,7 +167,8 @@ func PartitionsWithContext(ctx context.Context, _ bool) ([]PartitionStat, error)
nextVolHandle,
uintptr(unsafe.Pointer(&volNameBuf[0])),
uintptr(volumeNameBufferLength)); err != nil && volRet == 0 {
if errno, ok := err.(syscall.Errno); ok && errno == windows.ERROR_NO_MORE_FILES {
var errno syscall.Errno
if errors.As(err, &errno) && errno == windows.ERROR_NO_MORE_FILES {
break
}
warnings.Add(fmt.Errorf("failed to find next volume: %w", err))
@ -257,7 +260,9 @@ func IOCountersWithContext(_ context.Context, names ...string) (map[string]IOCou
return drivemap, err
}
for _, v := range lpBuffer[:lpBufferLen] {
if 'A' <= v && v <= 'Z' {
if v < 'A' || v > 'Z' {
continue
}
path := string(rune(v)) + ":"
typepath, _ := windows.UTF16PtrFromString(path)
typeret := windows.GetDriveType(typepath)
@ -293,7 +298,6 @@ func IOCountersWithContext(_ context.Context, names ...string) (map[string]IOCou
}
}
}
}
return drivemap, nil
}

@ -6,7 +6,6 @@ require (
github.com/ebitengine/purego v0.8.4
github.com/google/go-cmp v0.7.0
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0
github.com/pkg/errors v0.9.1
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c
github.com/stretchr/testify v1.10.0
github.com/tklauser/go-sysconf v0.3.12

@ -9,8 +9,6 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=

Loading…
Cancel
Save