From 81ca08f1b3ebd3d7b893e0bb39cd00e97827e1f7 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 3 May 2019 09:34:00 +0200 Subject: setupapi: safer aliasing of slice types --- tun/wintun/guid/zguid_windows.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tun/wintun/guid/zguid_windows.go') diff --git a/tun/wintun/guid/zguid_windows.go b/tun/wintun/guid/zguid_windows.go index 5467849..b0b4cce 100644 --- a/tun/wintun/guid/zguid_windows.go +++ b/tun/wintun/guid/zguid_windows.go @@ -42,8 +42,14 @@ var ( procCLSIDFromString = modole32.NewProc("CLSIDFromString") ) -func clsidFromString(lpsz *uint16, pclsid *windows.GUID) (hr int32) { - r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0) - hr = int32(r0) +func clsidFromString(lpsz *uint16, pclsid *windows.GUID) (err error) { + r1, _, e1 := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0) + if r1 != 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } return } -- cgit v1.2.3