Skip to content

Commit

Permalink
Do not expect return values from _GetNativeSystemInfo (#5)
Browse files Browse the repository at this point in the history
Do not use return value or error from _GetNativeSystemInfo because the underlying Windows function does not return a value.

Fixes #3
  • Loading branch information
strawgate authored and andrewkroh committed Jul 25, 2018
1 parent 5d078fa commit f11b8c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
6 changes: 2 additions & 4 deletions kernel32.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

// Syscalls
//sys _GetNativeSystemInfo(systemInfo *SystemInfo) (err error) = kernel32.GetNativeSystemInfo
//sys _GetNativeSystemInfo(systemInfo *SystemInfo) = kernel32.GetNativeSystemInfo
//sys _GetTickCount64() (millis uint64, err error) = kernel32.GetTickCount64
//sys _GetSystemTimes(idleTime *syscall.Filetime, kernelTime *syscall.Filetime, userTime *syscall.Filetime) (err error) = kernel32.GetSystemTimes
//sys _GlobalMemoryStatusEx(buffer *MemoryStatusEx) (err error) = kernel32.GlobalMemoryStatusEx
Expand Down Expand Up @@ -133,9 +133,7 @@ type MemoryStatusEx struct {
// https://msdn.microsoft.com/en-us/library/ms724340%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
func GetNativeSystemInfo() (SystemInfo, error) {
var systemInfo SystemInfo
if err := _GetNativeSystemInfo(&systemInfo); err != nil {
return SystemInfo{}, errors.Wrap(err, "GetNativeSystemInfo failed")
}
_GetNativeSystemInfo(&systemInfo)
return systemInfo, nil
}

Expand Down
11 changes: 2 additions & 9 deletions zsyscall_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,8 @@ var (
procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo")
)

func _GetNativeSystemInfo(systemInfo *SystemInfo) (err error) {
r1, _, e1 := syscall.Syscall(procGetNativeSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(systemInfo)), 0, 0)
if r1 == 0 {
if e1 != 0 {
err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
}
func _GetNativeSystemInfo(systemInfo *SystemInfo) {
syscall.Syscall(procGetNativeSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(systemInfo)), 0, 0)
return
}

Expand Down

0 comments on commit f11b8c9

Please sign in to comment.