mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
chore: ignore deprecated syscall.Syscall
This commit is contained in:
parent
6e1137512c
commit
6f71fc417a
|
@ -92,7 +92,7 @@ func uint32ToFloat64(num uint32) (float64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupDiSetup(proc *windows.LazyProc, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, error) {
|
func setupDiSetup(proc *windows.LazyProc, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, error) {
|
||||||
r1, _, errno := syscall.Syscall6(proc.Addr(), nargs, a1, a2, a3, a4, a5, a6)
|
r1, _, errno := syscall.Syscall6(proc.Addr(), nargs, a1, a2, a3, a4, a5, a6) //nolint:staticcheck
|
||||||
if windows.Handle(r1) == windows.InvalidHandle {
|
if windows.Handle(r1) == windows.InvalidHandle {
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
return 0, error(errno)
|
return 0, error(errno)
|
||||||
|
@ -103,7 +103,7 @@ func setupDiSetup(proc *windows.LazyProc, nargs, a1, a2, a3, a4, a5, a6 uintptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupDiCall(proc *windows.LazyProc, nargs, a1, a2, a3, a4, a5, a6 uintptr) syscall.Errno {
|
func setupDiCall(proc *windows.LazyProc, nargs, a1, a2, a3, a4, a5, a6 uintptr) syscall.Errno {
|
||||||
r1, _, errno := syscall.Syscall6(proc.Addr(), nargs, a1, a2, a3, a4, a5, a6)
|
r1, _, errno := syscall.Syscall6(proc.Addr(), nargs, a1, a2, a3, a4, a5, a6) //nolint:staticcheck
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
return errno
|
return errno
|
||||||
|
@ -144,11 +144,13 @@ func systemGet(idx int) (*battery, error) {
|
||||||
2|16, // DIGCF_PRESENT|DIGCF_DEVICEINTERFACE
|
2|16, // DIGCF_PRESENT|DIGCF_DEVICEINTERFACE
|
||||||
0, 0,
|
0, 0,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
_, _, _ = syscall.Syscall(setupDiDestroyDeviceInfoList.Addr(), 1, hdev, 0, 0)
|
_, _, _ = syscall.Syscall(setupDiDestroyDeviceInfoList.Addr(), 1, hdev, 0, 0) //nolint:staticcheck
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var did spDeviceInterfaceData
|
var did spDeviceInterfaceData
|
||||||
|
@ -163,12 +165,15 @@ func systemGet(idx int) (*battery, error) {
|
||||||
uintptr(unsafe.Pointer(&did)),
|
uintptr(unsafe.Pointer(&did)),
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
|
|
||||||
if errno == 259 { // ERROR_NO_MORE_ITEMS
|
if errno == 259 { // ERROR_NO_MORE_ITEMS
|
||||||
return nil, ErrNotFound
|
return nil, ErrNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
return nil, errno
|
return nil, errno
|
||||||
}
|
}
|
||||||
|
|
||||||
var cbRequired uint32
|
var cbRequired uint32
|
||||||
errno = setupDiCall(
|
errno = setupDiCall(
|
||||||
setupDiGetDeviceInterfaceDetailW,
|
setupDiGetDeviceInterfaceDetailW,
|
||||||
|
@ -180,9 +185,11 @@ func systemGet(idx int) (*battery, error) {
|
||||||
uintptr(unsafe.Pointer(&cbRequired)),
|
uintptr(unsafe.Pointer(&cbRequired)),
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
|
|
||||||
if errno != 0 && errno != 122 { // ERROR_INSUFFICIENT_BUFFER
|
if errno != 0 && errno != 122 { // ERROR_INSUFFICIENT_BUFFER
|
||||||
return nil, errno
|
return nil, errno
|
||||||
}
|
}
|
||||||
|
|
||||||
// The god damn struct with ANYSIZE_ARRAY of utf16 in it is crazy.
|
// The god damn struct with ANYSIZE_ARRAY of utf16 in it is crazy.
|
||||||
// So... let's emulate it with array of uint16 ;-D.
|
// So... let's emulate it with array of uint16 ;-D.
|
||||||
// Keep in mind that the first two elements are actually cbSize.
|
// Keep in mind that the first two elements are actually cbSize.
|
||||||
|
@ -193,6 +200,7 @@ func systemGet(idx int) (*battery, error) {
|
||||||
} else {
|
} else {
|
||||||
*cbSize = 6
|
*cbSize = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = setupDiCall(
|
errno = setupDiCall(
|
||||||
setupDiGetDeviceInterfaceDetailW,
|
setupDiGetDeviceInterfaceDetailW,
|
||||||
6,
|
6,
|
||||||
|
@ -203,9 +211,11 @@ func systemGet(idx int) (*battery, error) {
|
||||||
uintptr(unsafe.Pointer(&cbRequired)),
|
uintptr(unsafe.Pointer(&cbRequired)),
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
|
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
return nil, errno
|
return nil, errno
|
||||||
}
|
}
|
||||||
|
|
||||||
devicePath := &didd[2:][0]
|
devicePath := &didd[2:][0]
|
||||||
|
|
||||||
handle, err := windows.CreateFile(
|
handle, err := windows.CreateFile(
|
||||||
|
@ -217,9 +227,11 @@ func systemGet(idx int) (*battery, error) {
|
||||||
windows.FILE_ATTRIBUTE_NORMAL,
|
windows.FILE_ATTRIBUTE_NORMAL,
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
_ = windows.CloseHandle(handle)
|
_ = windows.CloseHandle(handle)
|
||||||
}()
|
}()
|
||||||
|
@ -238,9 +250,11 @@ func systemGet(idx int) (*battery, error) {
|
||||||
&dwOut,
|
&dwOut,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if bqi.BatteryTag == 0 {
|
if bqi.BatteryTag == 0 {
|
||||||
return nil, errors.New("BatteryTag not returned")
|
return nil, errors.New("BatteryTag not returned")
|
||||||
}
|
}
|
||||||
|
@ -258,6 +272,7 @@ func systemGet(idx int) (*battery, error) {
|
||||||
&dwOut,
|
&dwOut,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -276,6 +291,7 @@ func systemGet(idx int) (*battery, error) {
|
||||||
&dwOut,
|
&dwOut,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -283,9 +299,11 @@ func systemGet(idx int) (*battery, error) {
|
||||||
if b.Current, err = uint32ToFloat64(bs.Capacity); err != nil {
|
if b.Current, err = uint32ToFloat64(bs.Capacity); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.Voltage, err = uint32ToFloat64(bs.Voltage); err != nil {
|
if b.Voltage, err = uint32ToFloat64(bs.Voltage); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Voltage /= 1000
|
b.Voltage /= 1000
|
||||||
b.State = readState(bs.PowerState)
|
b.State = readState(bs.PowerState)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue