]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: do not use int to test network syscall results (on windows)
authorAlex Brainman <alex.brainman@gmail.com>
Tue, 25 Sep 2012 07:06:39 +0000 (17:06 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Tue, 25 Sep 2012 07:06:39 +0000 (17:06 +1000)
Fixes #4147.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6569050

src/pkg/syscall/mksyscall_windows.pl
src/pkg/syscall/syscall_windows.go
src/pkg/syscall/zsyscall_windows_386.go
src/pkg/syscall/zsyscall_windows_amd64.go

index 78d86af0687d1502d432587a8a1feabe04cde02b..0e015cb707522d8aae9a24054b5226d036394111 100755 (executable)
@@ -266,7 +266,7 @@ while(<>) {
                                $failexpr = "!$name";
                        } elsif($name eq "err") {
                                $ret[$i] = "r1";
-                               $failexpr = "int(r1) $failcond";
+                               $failexpr = "r1 $failcond";
                        } else {
                                $failexpr = "$name $failcond";
                        }
index ee57f1d0190b9f3eea865e03f715728c59bcd716..342eb569280338b3f560556312a2ba6bf4e464d9 100644 (file)
@@ -468,25 +468,27 @@ func Chmod(path string, mode uint32) (err error) {
 
 // net api calls
 
+const socket_error = uintptr(^uint32(0))
+
 //sys  WSAStartup(verreq uint32, data *WSAData) (sockerr error) = ws2_32.WSAStartup
-//sys  WSACleanup() (err error) [failretval==-1] = ws2_32.WSACleanup
-//sys  WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) [failretval==-1] = ws2_32.WSAIoctl
+//sys  WSACleanup() (err error) [failretval==socket_error] = ws2_32.WSACleanup
+//sys  WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) [failretval==socket_error] = ws2_32.WSAIoctl
 //sys  socket(af int32, typ int32, protocol int32) (handle Handle, err error) [failretval==InvalidHandle] = ws2_32.socket
-//sys  Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) [failretval==-1] = ws2_32.setsockopt
-//sys  Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) [failretval==-1] = ws2_32.getsockopt
-//sys  bind(s Handle, name uintptr, namelen int32) (err error) [failretval==-1] = ws2_32.bind
-//sys  connect(s Handle, name uintptr, namelen int32) (err error) [failretval==-1] = ws2_32.connect
-//sys  getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) [failretval==-1] = ws2_32.getsockname
-//sys  getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) [failretval==-1] = ws2_32.getpeername
-//sys  listen(s Handle, backlog int32) (err error) [failretval==-1] = ws2_32.listen
-//sys  shutdown(s Handle, how int32) (err error) [failretval==-1] = ws2_32.shutdown
-//sys  Closesocket(s Handle) (err error) [failretval==-1] = ws2_32.closesocket
+//sys  Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) [failretval==socket_error] = ws2_32.setsockopt
+//sys  Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) [failretval==socket_error] = ws2_32.getsockopt
+//sys  bind(s Handle, name uintptr, namelen int32) (err error) [failretval==socket_error] = ws2_32.bind
+//sys  connect(s Handle, name uintptr, namelen int32) (err error) [failretval==socket_error] = ws2_32.connect
+//sys  getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) [failretval==socket_error] = ws2_32.getsockname
+//sys  getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) [failretval==socket_error] = ws2_32.getpeername
+//sys  listen(s Handle, backlog int32) (err error) [failretval==socket_error] = ws2_32.listen
+//sys  shutdown(s Handle, how int32) (err error) [failretval==socket_error] = ws2_32.shutdown
+//sys  Closesocket(s Handle) (err error) [failretval==socket_error] = ws2_32.closesocket
 //sys  AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) = mswsock.AcceptEx
 //sys  GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) = mswsock.GetAcceptExSockaddrs
-//sys  WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) [failretval==-1] = ws2_32.WSARecv
-//sys  WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) [failretval==-1] = ws2_32.WSASend
-//sys  WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32,  from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) [failretval==-1] = ws2_32.WSARecvFrom
-//sys  WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32,  overlapped *Overlapped, croutine *byte) (err error) [failretval==-1] = ws2_32.WSASendTo
+//sys  WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSARecv
+//sys  WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSASend
+//sys  WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32,  from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSARecvFrom
+//sys  WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32,  overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSASendTo
 //sys  GetHostByName(name string) (h *Hostent, err error) [failretval==nil] = ws2_32.gethostbyname
 //sys  GetServByName(name string, proto string) (s *Servent, err error) [failretval==nil] = ws2_32.getservbyname
 //sys  Ntohs(netshort uint16) (u uint16) = ws2_32.ntohs
index af8569924d64adcf83308d558798de06b922a1ef..f2b359672d35ab20644bee2b634803ddc8a05d3c 100644 (file)
@@ -176,7 +176,7 @@ func LoadLibrary(libname string) (handle Handle, err error) {
 
 func FreeLibrary(handle Handle) (err error) {
        r1, _, e1 := Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -258,7 +258,7 @@ func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (
                _p0 = &buf[0]
        }
        r1, _, e1 := Syscall6(procReadFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -274,7 +274,7 @@ func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped)
                _p0 = &buf[0]
        }
        r1, _, e1 := Syscall6(procWriteFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -299,7 +299,7 @@ func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence
 
 func CloseHandle(handle Handle) (err error) {
        r1, _, e1 := Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -337,7 +337,7 @@ func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err erro
 
 func findNextFile1(handle Handle, data *win32finddata1) (err error) {
        r1, _, e1 := Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -349,7 +349,7 @@ func findNextFile1(handle Handle, data *win32finddata1) (err error) {
 
 func FindClose(handle Handle) (err error) {
        r1, _, e1 := Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -361,7 +361,7 @@ func FindClose(handle Handle) (err error) {
 
 func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
        r1, _, e1 := Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -386,7 +386,7 @@ func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
 
 func SetCurrentDirectory(path *uint16) (err error) {
        r1, _, e1 := Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -398,7 +398,7 @@ func SetCurrentDirectory(path *uint16) (err error) {
 
 func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
        r1, _, e1 := Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -410,7 +410,7 @@ func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
 
 func RemoveDirectory(path *uint16) (err error) {
        r1, _, e1 := Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -422,7 +422,7 @@ func RemoveDirectory(path *uint16) (err error) {
 
 func DeleteFile(path *uint16) (err error) {
        r1, _, e1 := Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -434,7 +434,7 @@ func DeleteFile(path *uint16) (err error) {
 
 func MoveFile(from *uint16, to *uint16) (err error) {
        r1, _, e1 := Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -446,7 +446,7 @@ func MoveFile(from *uint16, to *uint16) (err error) {
 
 func GetComputerName(buf *uint16, n *uint32) (err error) {
        r1, _, e1 := Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -458,7 +458,7 @@ func GetComputerName(buf *uint16, n *uint32) (err error) {
 
 func SetEndOfFile(handle Handle) (err error) {
        r1, _, e1 := Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -501,7 +501,7 @@ func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, thre
 
 func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
        r1, _, e1 := Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -513,7 +513,7 @@ func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overla
 
 func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
        r1, _, e1 := Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -525,7 +525,7 @@ func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlap
 
 func CancelIo(s Handle) (err error) {
        r1, _, e1 := Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -543,7 +543,7 @@ func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityA
                _p0 = 0
        }
        r1, _, e1 := Syscall12(procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -574,7 +574,7 @@ func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err
 
 func TerminateProcess(handle Handle, exitcode uint32) (err error) {
        r1, _, e1 := Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -586,7 +586,7 @@ func TerminateProcess(handle Handle, exitcode uint32) (err error) {
 
 func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
        r1, _, e1 := Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -598,7 +598,7 @@ func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
 
 func GetStartupInfo(startupInfo *StartupInfo) (err error) {
        r1, _, e1 := Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -623,7 +623,7 @@ func GetCurrentProcess() (pseudoHandle Handle, err error) {
 
 func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
        r1, _, e1 := Syscall6(procGetProcessTimes.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(creationTime)), uintptr(unsafe.Pointer(exitTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -641,7 +641,7 @@ func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetP
                _p0 = 0
        }
        r1, _, e1 := Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -679,7 +679,7 @@ func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
 
 func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
        r1, _, e1 := Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -704,7 +704,7 @@ func GetFileType(filehandle Handle) (n uint32, err error) {
 
 func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
        r1, _, e1 := Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -716,7 +716,7 @@ func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16
 
 func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
        r1, _, e1 := Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -728,7 +728,7 @@ func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
 
 func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
        r1, _, e1 := Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -753,7 +753,7 @@ func GetEnvironmentStrings() (envs *uint16, err error) {
 
 func FreeEnvironmentStrings(envs *uint16) (err error) {
        r1, _, e1 := Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -778,7 +778,7 @@ func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32
 
 func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
        r1, _, e1 := Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -790,7 +790,7 @@ func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
 
 func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
        r1, _, e1 := Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -815,7 +815,7 @@ func GetFileAttributes(name *uint16) (attrs uint32, err error) {
 
 func SetFileAttributes(name *uint16, attrs uint32) (err error) {
        r1, _, e1 := Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -827,7 +827,7 @@ func SetFileAttributes(name *uint16, attrs uint32) (err error) {
 
 func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
        r1, _, e1 := Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -871,7 +871,7 @@ func LocalFree(hmem Handle) (handle Handle, err error) {
 
 func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
        r1, _, e1 := Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -883,7 +883,7 @@ func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error)
 
 func FlushFileBuffers(handle Handle) (err error) {
        r1, _, e1 := Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -960,7 +960,7 @@ func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow ui
 
 func UnmapViewOfFile(addr uintptr) (err error) {
        r1, _, e1 := Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -972,7 +972,7 @@ func UnmapViewOfFile(addr uintptr) (err error) {
 
 func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
        r1, _, e1 := Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -984,7 +984,7 @@ func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
 
 func VirtualLock(addr uintptr, length uintptr) (err error) {
        r1, _, e1 := Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -996,7 +996,7 @@ func VirtualLock(addr uintptr, length uintptr) (err error) {
 
 func VirtualUnlock(addr uintptr, length uintptr) (err error) {
        r1, _, e1 := Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1008,7 +1008,7 @@ func VirtualUnlock(addr uintptr, length uintptr) (err error) {
 
 func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
        r1, _, e1 := Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1026,7 +1026,7 @@ func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree
                _p0 = 0
        }
        r1, _, e1 := Syscall9(procReadDirectoryChangesW.Addr(), 8, uintptr(handle), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(_p0), uintptr(mask), uintptr(unsafe.Pointer(retlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1077,7 +1077,7 @@ func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (contex
 
 func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
        r1, _, e1 := Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1089,7 +1089,7 @@ func CertAddCertificateContextToStore(store Handle, certContext *CertContext, ad
 
 func CertCloseStore(store Handle, flags uint32) (err error) {
        r1, _, e1 := Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1101,7 +1101,7 @@ func CertCloseStore(store Handle, flags uint32) (err error) {
 
 func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
        r1, _, e1 := Syscall9(procCertGetCertificateChain.Addr(), 8, uintptr(engine), uintptr(unsafe.Pointer(leaf)), uintptr(unsafe.Pointer(time)), uintptr(additionalStore), uintptr(unsafe.Pointer(para)), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(chainCtx)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1131,7 +1131,7 @@ func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, en
 
 func CertFreeCertificateContext(ctx *CertContext) (err error) {
        r1, _, e1 := Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1143,7 +1143,7 @@ func CertFreeCertificateContext(ctx *CertContext) (err error) {
 
 func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
        r1, _, e1 := Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1201,7 +1201,7 @@ func getCurrentProcessId() (pid uint32) {
 
 func GetConsoleMode(console Handle, mode *uint32) (err error) {
        r1, _, e1 := Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1213,7 +1213,7 @@ func GetConsoleMode(console Handle, mode *uint32) (err error) {
 
 func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
        r1, _, e1 := Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1233,7 +1233,7 @@ func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
 
 func WSACleanup() (err error) {
        r1, _, e1 := Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1245,7 +1245,7 @@ func WSACleanup() (err error) {
 
 func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
        r1, _, e1 := Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1270,7 +1270,7 @@ func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
 
 func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
        r1, _, e1 := Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1282,7 +1282,7 @@ func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32
 
 func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
        r1, _, e1 := Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1294,7 +1294,7 @@ func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int3
 
 func bind(s Handle, name uintptr, namelen int32) (err error) {
        r1, _, e1 := Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1306,7 +1306,7 @@ func bind(s Handle, name uintptr, namelen int32) (err error) {
 
 func connect(s Handle, name uintptr, namelen int32) (err error) {
        r1, _, e1 := Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1318,7 +1318,7 @@ func connect(s Handle, name uintptr, namelen int32) (err error) {
 
 func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
        r1, _, e1 := Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1330,7 +1330,7 @@ func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
 
 func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
        r1, _, e1 := Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1342,7 +1342,7 @@ func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
 
 func listen(s Handle, backlog int32) (err error) {
        r1, _, e1 := Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1354,7 +1354,7 @@ func listen(s Handle, backlog int32) (err error) {
 
 func shutdown(s Handle, how int32) (err error) {
        r1, _, e1 := Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1366,7 +1366,7 @@ func shutdown(s Handle, how int32) (err error) {
 
 func Closesocket(s Handle) (err error) {
        r1, _, e1 := Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1378,7 +1378,7 @@ func Closesocket(s Handle) (err error) {
 
 func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
        r1, _, e1 := Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1395,7 +1395,7 @@ func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen
 
 func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
        r1, _, e1 := Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1407,7 +1407,7 @@ func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32
 
 func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
        r1, _, e1 := Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1419,7 +1419,7 @@ func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32,
 
 func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
        r1, _, e1 := Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1431,7 +1431,7 @@ func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *ui
 
 func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
        r1, _, e1 := Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1542,7 +1542,7 @@ func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) {
 
 func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
        r1, _, e1 := Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
-       if int(r1)&0xff == 0 {
+       if r1&0xff == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1554,7 +1554,7 @@ func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint
 
 func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
        r1, _, e1 := Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
-       if int(r1)&0xff == 0 {
+       if r1&0xff == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1582,7 +1582,7 @@ func NetApiBufferFree(buf *byte) (neterr error) {
 
 func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
        r1, _, e1 := Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1594,7 +1594,7 @@ func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint3
 
 func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
        r1, _, e1 := Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1606,7 +1606,7 @@ func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen
 
 func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
        r1, _, e1 := Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1618,7 +1618,7 @@ func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
 
 func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
        r1, _, e1 := Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1636,7 +1636,7 @@ func GetLengthSid(sid *SID) (len uint32) {
 
 func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
        r1, _, e1 := Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1648,7 +1648,7 @@ func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
 
 func OpenProcessToken(h Handle, access uint32, token *Token) (err error) {
        r1, _, e1 := Syscall(procOpenProcessToken.Addr(), 3, uintptr(h), uintptr(access), uintptr(unsafe.Pointer(token)))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1660,7 +1660,7 @@ func OpenProcessToken(h Handle, access uint32, token *Token) (err error) {
 
 func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
        r1, _, e1 := Syscall6(procGetTokenInformation.Addr(), 5, uintptr(t), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1672,7 +1672,7 @@ func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32,
 
 func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
        r1, _, e1 := Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
index 74f9bf6fc400db1376377844fd65ac98f778cce7..37270fa5909bb50703820d041fe5646d1db4b045 100644 (file)
@@ -176,7 +176,7 @@ func LoadLibrary(libname string) (handle Handle, err error) {
 
 func FreeLibrary(handle Handle) (err error) {
        r1, _, e1 := Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -258,7 +258,7 @@ func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (
                _p0 = &buf[0]
        }
        r1, _, e1 := Syscall6(procReadFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -274,7 +274,7 @@ func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped)
                _p0 = &buf[0]
        }
        r1, _, e1 := Syscall6(procWriteFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -299,7 +299,7 @@ func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence
 
 func CloseHandle(handle Handle) (err error) {
        r1, _, e1 := Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -337,7 +337,7 @@ func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err erro
 
 func findNextFile1(handle Handle, data *win32finddata1) (err error) {
        r1, _, e1 := Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -349,7 +349,7 @@ func findNextFile1(handle Handle, data *win32finddata1) (err error) {
 
 func FindClose(handle Handle) (err error) {
        r1, _, e1 := Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -361,7 +361,7 @@ func FindClose(handle Handle) (err error) {
 
 func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
        r1, _, e1 := Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -386,7 +386,7 @@ func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
 
 func SetCurrentDirectory(path *uint16) (err error) {
        r1, _, e1 := Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -398,7 +398,7 @@ func SetCurrentDirectory(path *uint16) (err error) {
 
 func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
        r1, _, e1 := Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -410,7 +410,7 @@ func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
 
 func RemoveDirectory(path *uint16) (err error) {
        r1, _, e1 := Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -422,7 +422,7 @@ func RemoveDirectory(path *uint16) (err error) {
 
 func DeleteFile(path *uint16) (err error) {
        r1, _, e1 := Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -434,7 +434,7 @@ func DeleteFile(path *uint16) (err error) {
 
 func MoveFile(from *uint16, to *uint16) (err error) {
        r1, _, e1 := Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -446,7 +446,7 @@ func MoveFile(from *uint16, to *uint16) (err error) {
 
 func GetComputerName(buf *uint16, n *uint32) (err error) {
        r1, _, e1 := Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -458,7 +458,7 @@ func GetComputerName(buf *uint16, n *uint32) (err error) {
 
 func SetEndOfFile(handle Handle) (err error) {
        r1, _, e1 := Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -501,7 +501,7 @@ func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, thre
 
 func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
        r1, _, e1 := Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -513,7 +513,7 @@ func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overla
 
 func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
        r1, _, e1 := Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -525,7 +525,7 @@ func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlap
 
 func CancelIo(s Handle) (err error) {
        r1, _, e1 := Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -543,7 +543,7 @@ func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityA
                _p0 = 0
        }
        r1, _, e1 := Syscall12(procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -574,7 +574,7 @@ func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err
 
 func TerminateProcess(handle Handle, exitcode uint32) (err error) {
        r1, _, e1 := Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -586,7 +586,7 @@ func TerminateProcess(handle Handle, exitcode uint32) (err error) {
 
 func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
        r1, _, e1 := Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -598,7 +598,7 @@ func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
 
 func GetStartupInfo(startupInfo *StartupInfo) (err error) {
        r1, _, e1 := Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -623,7 +623,7 @@ func GetCurrentProcess() (pseudoHandle Handle, err error) {
 
 func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
        r1, _, e1 := Syscall6(procGetProcessTimes.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(creationTime)), uintptr(unsafe.Pointer(exitTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -641,7 +641,7 @@ func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetP
                _p0 = 0
        }
        r1, _, e1 := Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -679,7 +679,7 @@ func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
 
 func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
        r1, _, e1 := Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -704,7 +704,7 @@ func GetFileType(filehandle Handle) (n uint32, err error) {
 
 func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
        r1, _, e1 := Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -716,7 +716,7 @@ func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16
 
 func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
        r1, _, e1 := Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -728,7 +728,7 @@ func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
 
 func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
        r1, _, e1 := Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -753,7 +753,7 @@ func GetEnvironmentStrings() (envs *uint16, err error) {
 
 func FreeEnvironmentStrings(envs *uint16) (err error) {
        r1, _, e1 := Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -778,7 +778,7 @@ func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32
 
 func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
        r1, _, e1 := Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -790,7 +790,7 @@ func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
 
 func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
        r1, _, e1 := Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -815,7 +815,7 @@ func GetFileAttributes(name *uint16) (attrs uint32, err error) {
 
 func SetFileAttributes(name *uint16, attrs uint32) (err error) {
        r1, _, e1 := Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -827,7 +827,7 @@ func SetFileAttributes(name *uint16, attrs uint32) (err error) {
 
 func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
        r1, _, e1 := Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -871,7 +871,7 @@ func LocalFree(hmem Handle) (handle Handle, err error) {
 
 func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
        r1, _, e1 := Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -883,7 +883,7 @@ func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error)
 
 func FlushFileBuffers(handle Handle) (err error) {
        r1, _, e1 := Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -960,7 +960,7 @@ func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow ui
 
 func UnmapViewOfFile(addr uintptr) (err error) {
        r1, _, e1 := Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -972,7 +972,7 @@ func UnmapViewOfFile(addr uintptr) (err error) {
 
 func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
        r1, _, e1 := Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -984,7 +984,7 @@ func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
 
 func VirtualLock(addr uintptr, length uintptr) (err error) {
        r1, _, e1 := Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -996,7 +996,7 @@ func VirtualLock(addr uintptr, length uintptr) (err error) {
 
 func VirtualUnlock(addr uintptr, length uintptr) (err error) {
        r1, _, e1 := Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1008,7 +1008,7 @@ func VirtualUnlock(addr uintptr, length uintptr) (err error) {
 
 func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
        r1, _, e1 := Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1026,7 +1026,7 @@ func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree
                _p0 = 0
        }
        r1, _, e1 := Syscall9(procReadDirectoryChangesW.Addr(), 8, uintptr(handle), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(_p0), uintptr(mask), uintptr(unsafe.Pointer(retlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1077,7 +1077,7 @@ func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (contex
 
 func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
        r1, _, e1 := Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1089,7 +1089,7 @@ func CertAddCertificateContextToStore(store Handle, certContext *CertContext, ad
 
 func CertCloseStore(store Handle, flags uint32) (err error) {
        r1, _, e1 := Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1101,7 +1101,7 @@ func CertCloseStore(store Handle, flags uint32) (err error) {
 
 func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
        r1, _, e1 := Syscall9(procCertGetCertificateChain.Addr(), 8, uintptr(engine), uintptr(unsafe.Pointer(leaf)), uintptr(unsafe.Pointer(time)), uintptr(additionalStore), uintptr(unsafe.Pointer(para)), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(chainCtx)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1131,7 +1131,7 @@ func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, en
 
 func CertFreeCertificateContext(ctx *CertContext) (err error) {
        r1, _, e1 := Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1143,7 +1143,7 @@ func CertFreeCertificateContext(ctx *CertContext) (err error) {
 
 func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
        r1, _, e1 := Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1201,7 +1201,7 @@ func getCurrentProcessId() (pid uint32) {
 
 func GetConsoleMode(console Handle, mode *uint32) (err error) {
        r1, _, e1 := Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1213,7 +1213,7 @@ func GetConsoleMode(console Handle, mode *uint32) (err error) {
 
 func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
        r1, _, e1 := Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1233,7 +1233,7 @@ func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
 
 func WSACleanup() (err error) {
        r1, _, e1 := Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1245,7 +1245,7 @@ func WSACleanup() (err error) {
 
 func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
        r1, _, e1 := Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1270,7 +1270,7 @@ func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
 
 func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
        r1, _, e1 := Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1282,7 +1282,7 @@ func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32
 
 func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
        r1, _, e1 := Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1294,7 +1294,7 @@ func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int3
 
 func bind(s Handle, name uintptr, namelen int32) (err error) {
        r1, _, e1 := Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1306,7 +1306,7 @@ func bind(s Handle, name uintptr, namelen int32) (err error) {
 
 func connect(s Handle, name uintptr, namelen int32) (err error) {
        r1, _, e1 := Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1318,7 +1318,7 @@ func connect(s Handle, name uintptr, namelen int32) (err error) {
 
 func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
        r1, _, e1 := Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1330,7 +1330,7 @@ func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
 
 func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
        r1, _, e1 := Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1342,7 +1342,7 @@ func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
 
 func listen(s Handle, backlog int32) (err error) {
        r1, _, e1 := Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1354,7 +1354,7 @@ func listen(s Handle, backlog int32) (err error) {
 
 func shutdown(s Handle, how int32) (err error) {
        r1, _, e1 := Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1366,7 +1366,7 @@ func shutdown(s Handle, how int32) (err error) {
 
 func Closesocket(s Handle) (err error) {
        r1, _, e1 := Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1378,7 +1378,7 @@ func Closesocket(s Handle) (err error) {
 
 func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
        r1, _, e1 := Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1395,7 +1395,7 @@ func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen
 
 func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
        r1, _, e1 := Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1407,7 +1407,7 @@ func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32
 
 func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
        r1, _, e1 := Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1419,7 +1419,7 @@ func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32,
 
 func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
        r1, _, e1 := Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1431,7 +1431,7 @@ func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *ui
 
 func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
        r1, _, e1 := Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
-       if int(r1) == -1 {
+       if r1 == socket_error {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1542,7 +1542,7 @@ func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) {
 
 func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
        r1, _, e1 := Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
-       if int(r1)&0xff == 0 {
+       if r1&0xff == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1554,7 +1554,7 @@ func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint
 
 func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
        r1, _, e1 := Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
-       if int(r1)&0xff == 0 {
+       if r1&0xff == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1582,7 +1582,7 @@ func NetApiBufferFree(buf *byte) (neterr error) {
 
 func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
        r1, _, e1 := Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1594,7 +1594,7 @@ func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint3
 
 func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
        r1, _, e1 := Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1606,7 +1606,7 @@ func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen
 
 func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
        r1, _, e1 := Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1618,7 +1618,7 @@ func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
 
 func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
        r1, _, e1 := Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1636,7 +1636,7 @@ func GetLengthSid(sid *SID) (len uint32) {
 
 func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
        r1, _, e1 := Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1648,7 +1648,7 @@ func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
 
 func OpenProcessToken(h Handle, access uint32, token *Token) (err error) {
        r1, _, e1 := Syscall(procOpenProcessToken.Addr(), 3, uintptr(h), uintptr(access), uintptr(unsafe.Pointer(token)))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1660,7 +1660,7 @@ func OpenProcessToken(h Handle, access uint32, token *Token) (err error) {
 
 func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
        r1, _, e1 := Syscall6(procGetTokenInformation.Addr(), 5, uintptr(t), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {
@@ -1672,7 +1672,7 @@ func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32,
 
 func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
        r1, _, e1 := Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
-       if int(r1) == 0 {
+       if r1 == 0 {
                if e1 != 0 {
                        err = error(e1)
                } else {