windows/mkwinsyscall: simplify generated code for booleans

Change-Id: I31ca4f93924a593e7952c483084616141998a03c
GitHub-Last-Rev: d4fd0c7eca99ed2c22400d819388168e830ce529
GitHub-Pull-Request: golang/sys#88
Reviewed-on: https://go-review.googlesource.com/c/sys/+/259302
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
diff --git a/windows/mkwinsyscall/mkwinsyscall.go b/windows/mkwinsyscall/mkwinsyscall.go
index ff2048b..910556e 100644
--- a/windows/mkwinsyscall/mkwinsyscall.go
+++ b/windows/mkwinsyscall/mkwinsyscall.go
@@ -105,26 +105,20 @@
 
 // BoolTmpVarCode returns source code for bool temp variable.
 func (p *Param) BoolTmpVarCode() string {
-	const code = `var %s uint32
-	if %s {
-		%s = 1
-	} else {
-		%s = 0
+	const code = `var %[1]s uint32
+	if %[2]s {
+		%[1]s = 1
 	}`
-	tmp := p.tmpVar()
-	return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
+	return fmt.Sprintf(code, p.tmpVar(), p.Name)
 }
 
 // BoolPointerTmpVarCode returns source code for bool temp variable.
 func (p *Param) BoolPointerTmpVarCode() string {
-	const code = `var %s uint32
-	if *%s {
-		%s = 1
-	} else {
-		%s = 0
+	const code = `var %[1]s uint32
+	if *%[2]s {
+		%[1]s = 1
 	}`
-	tmp := p.tmpVar()
-	return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
+	return fmt.Sprintf(code, p.tmpVar(), p.Name)
 }
 
 // SliceTmpVarCode returns source code for slice temp variable.
diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go
index f6cef2b..9c048fd 100644
--- a/windows/zsyscall_windows.go
+++ b/windows/zsyscall_windows.go
@@ -763,8 +763,6 @@
 	var _p0 uint32
 	if *isWow64 {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(&_p0)), 0)
 	*isWow64 = _p0 != 0
@@ -827,8 +825,6 @@
 	var _p0 uint32
 	if wait {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
 	if r1 == 0 {
@@ -1185,8 +1181,6 @@
 	var _p0 uint32
 	if inheritHandles {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.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 r1 == 0 {
@@ -1203,8 +1197,6 @@
 	var _p0 uint32
 	if inheritHandle {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(processId))
 	handle = Handle(r0)
@@ -1290,8 +1282,6 @@
 	var _p0 uint32
 	if bInheritHandle {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0)
 	if r1 == 0 {
@@ -1321,8 +1311,6 @@
 	var _p0 uint32
 	if waitAll {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
 	event = uint32(r0)
@@ -1464,8 +1452,6 @@
 	var _p0 uint32
 	if inheritExisting {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
 	if r1 == 0 {
@@ -1767,8 +1753,6 @@
 	var _p0 uint32
 	if watchSubTree {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.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 r1 == 0 {
@@ -2161,8 +2145,6 @@
 	var _p0 uint32
 	if inheritHandle {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
 	handle = Handle(r0)
@@ -2216,8 +2198,6 @@
 	var _p0 uint32
 	if initialOwner {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name)))
 	handle = Handle(r0)
@@ -2248,8 +2228,6 @@
 	var _p0 uint32
 	if inheritHandle {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r0, _, e1 := syscall.Syscall(procOpenMutexW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
 	handle = Handle(r0)
@@ -2279,8 +2257,6 @@
 	var _p0 uint32
 	if alertable {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0)
 	ret = uint32(r0)
@@ -2422,8 +2398,6 @@
 	var _p0 uint32
 	if inheritHandle {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId))
 	handle = Handle(r0)
@@ -2441,8 +2415,6 @@
 	var _p0 uint32
 	if disable {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall(procSetProcessPriorityBoost.Addr(), 2, uintptr(process), uintptr(_p0), 0)
 	if r1 == 0 {
@@ -2740,14 +2712,10 @@
 	var _p0 uint32
 	if forceAppsClosed {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	var _p1 uint32
 	if rebootAfterShutdown {
 		_p1 = 1
-	} else {
-		_p1 = 0
 	}
 	r1, _, e1 := syscall.Syscall6(procInitiateSystemShutdownExW.Addr(), 6, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(message)), uintptr(timeout), uintptr(_p0), uintptr(_p1), uintptr(reason))
 	if r1 == 0 {
@@ -3539,8 +3507,6 @@
 	var _p0 uint32
 	if openAsSelf {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
 	if r1 == 0 {
@@ -3605,8 +3571,6 @@
 	var _p0 uint32
 	if disableAllPrivileges {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
 	if r1 == 0 {
@@ -3623,8 +3587,6 @@
 	var _p0 uint32
 	if resetToDefault {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall6(procAdjustTokenGroups.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
 	if r1 == 0 {
@@ -3836,14 +3798,10 @@
 	var _p0 uint32
 	if *daclPresent {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	var _p1 uint32
 	if *daclDefaulted {
 		_p1 = 1
-	} else {
-		_p1 = 0
 	}
 	r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0)
 	*daclPresent = _p0 != 0
@@ -3862,14 +3820,10 @@
 	var _p0 uint32
 	if *saclPresent {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	var _p1 uint32
 	if *saclDefaulted {
 		_p1 = 1
-	} else {
-		_p1 = 0
 	}
 	r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0)
 	*saclPresent = _p0 != 0
@@ -3888,8 +3842,6 @@
 	var _p0 uint32
 	if *ownerDefaulted {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(&_p0)))
 	*ownerDefaulted = _p0 != 0
@@ -3907,8 +3859,6 @@
 	var _p0 uint32
 	if *groupDefaulted {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(&_p0)))
 	*groupDefaulted = _p0 != 0
@@ -3958,14 +3908,10 @@
 	var _p0 uint32
 	if daclPresent {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	var _p1 uint32
 	if daclDefaulted {
 		_p1 = 1
-	} else {
-		_p1 = 0
 	}
 	r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(dacl)), uintptr(_p1), 0, 0)
 	if r1 == 0 {
@@ -3982,14 +3928,10 @@
 	var _p0 uint32
 	if saclPresent {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	var _p1 uint32
 	if saclDefaulted {
 		_p1 = 1
-	} else {
-		_p1 = 0
 	}
 	r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(sacl)), uintptr(_p1), 0, 0)
 	if r1 == 0 {
@@ -4006,8 +3948,6 @@
 	var _p0 uint32
 	if ownerDefaulted {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(_p0))
 	if r1 == 0 {
@@ -4024,8 +3964,6 @@
 	var _p0 uint32
 	if groupDefaulted {
 		_p0 = 1
-	} else {
-		_p0 = 0
 	}
 	r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(_p0))
 	if r1 == 0 {