Skip to content

Commit

Permalink
fix PR review
Browse files Browse the repository at this point in the history
Signed-off-by: Dani Louca <[email protected]>
  • Loading branch information
dloucasfx committed Jan 8, 2024
1 parent acd2212 commit a94b92c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
16 changes: 8 additions & 8 deletions disk/disk_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"unicode/utf16"
"unsafe"

"github.com/pkg/errors"
"github.com/shirou/gopsutil/v3/internal/common"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/registry"
Expand Down Expand Up @@ -110,7 +109,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
uintptr(unsafe.Pointer(&volNameBuf[0])),
uintptr(volumeNameBufferLength))
if windows.Handle(nextVolHandle) == windows.InvalidHandle {
errFirstVol = errors.WithMessagef(err, "failed to get first-volume")
errFirstVol = fmt.Errorf("failed to get first-volume: %w", err)
return
}
defer procFindVolumeClose.Call(nextVolHandle)
Expand All @@ -128,14 +127,14 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
if errno, ok := err.(syscall.Errno); ok && errno == windows.ERROR_NO_MORE_FILES {
break
}
warnings.Add(errors.WithMessagef(err, "failed to find next volume"))
warnings.Add(fmt.Errorf("failed to find next volume: %w", err))
continue
}
}

firstVolume = false
if volPaths, err = getVolumePaths(volNameBuf); err != nil {
warnings.Add(errors.WithMessagef(err, "failed to find paths for volume %s", windows.UTF16ToString(volNameBuf)))
warnings.Add(fmt.Errorf("failed to find paths for volume %s", windows.UTF16ToString(volNameBuf)))
continue
}

Expand All @@ -154,19 +153,20 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
volNameBuf := make([]uint16, 256)
volSerialNum := uint32(0)
maxComponentLen := uint32(0)
if driveRet, _, err := procGetVolumeInformationW.Call(
driveRet, _, err := procGetVolumeInformationW.Call(
uintptr(unsafe.Pointer(rootPathPtr)),
uintptr(unsafe.Pointer(&volNameBuf[0])),
uintptr(len(volNameBuf)),
uintptr(unsafe.Pointer(&volSerialNum)),
uintptr(unsafe.Pointer(&maxComponentLen)),
uintptr(unsafe.Pointer(&fsFlags)),
uintptr(unsafe.Pointer(&fsNameBuf[0])),
uintptr(len(fsNameBuf))); err != nil && driveRet == 0 {
if driveType == windows.DRIVE_CDROM && driveType == windows.DRIVE_REMOVABLE {
uintptr(len(fsNameBuf)))
if err != nil && driveRet == 0 {
if driveType == windows.DRIVE_CDROM || driveType == windows.DRIVE_REMOVABLE {
continue
}
warnings.Add(errors.WithMessagef(err, "failed to get volume information"))
warnings.Add(fmt.Errorf("failed to get volume information: %w", err))
continue
}
opts := []string{"rw"}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.15
require (
github.com/google/go-cmp v0.6.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/shoenig/go-m1cpu v0.1.6
github.com/stretchr/testify v1.8.4
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
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=
Expand Down

0 comments on commit a94b92c

Please sign in to comment.