From f3755d9eba1147eb2cc3257689764f0cd8aac77b Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Tue, 17 Feb 2026 16:13:41 +1100 Subject: [PATCH] internal/syscall/windows: use byte instead of bool for all BOOLEAN Windows data types According to https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types BOOLEAN is defined as BYTE, and BYTE is equivalent to Go byte. This CL corrects CL 713480. It adjusts FILE_DISPOSITION_INFO.DeleteFile, FILE_DISPOSITION_INFORMATION.DeleteFile, FILE_RENAME_INFORMATION.ReplaceIfExists and FILE_LINK_INFORMATION.ReplaceIfExists to use byte instead of bool type. Updates #75922 Change-Id: Ifadc9696becb076b1403ca2e780d973e3d3dad69 Reviewed-on: https://go-review.googlesource.com/c/go/+/746061 Reviewed-by: Quim Muntal LUCI-TryBot-Result: Go LUCI Reviewed-by: Mark Freeman Reviewed-by: Junyang Shao --- src/internal/syscall/windows/at_windows.go | 6 +++--- src/internal/syscall/windows/types_windows.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/internal/syscall/windows/at_windows.go b/src/internal/syscall/windows/at_windows.go index f1360872f5..a5601493d8 100644 --- a/src/internal/syscall/windows/at_windows.go +++ b/src/internal/syscall/windows/at_windows.go @@ -355,7 +355,7 @@ func deleteatFallback(h syscall.Handle) error { h, FileDispositionInfo, unsafe.Pointer(&FILE_DISPOSITION_INFO{ - DeleteFile: true, + DeleteFile: 1, }), uint32(unsafe.Sizeof(FILE_DISPOSITION_INFO{})), ) @@ -416,7 +416,7 @@ func Renameat(olddirfd syscall.Handle, oldpath string, newdirfd syscall.Handle, // // Try again. renameInfo := FILE_RENAME_INFORMATION{ - ReplaceIfExists: true, + ReplaceIfExists: 1, RootDirectory: newdirfd, } copy(renameInfo.FileName[:], p16) @@ -602,7 +602,7 @@ func symlinkat(oldname string, newdirfd syscall.Handle, newname string, flags Sy h, &IO_STATUS_BLOCK{}, unsafe.Pointer(&FILE_DISPOSITION_INFORMATION{ - DeleteFile: true, + DeleteFile: 1, }), uint32(unsafe.Sizeof(FILE_DISPOSITION_INFORMATION{})), FileDispositionInformation, diff --git a/src/internal/syscall/windows/types_windows.go b/src/internal/syscall/windows/types_windows.go index 21aeb8faf9..a3d92b2b35 100644 --- a/src/internal/syscall/windows/types_windows.go +++ b/src/internal/syscall/windows/types_windows.go @@ -219,12 +219,12 @@ const ( // https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_disposition_info type FILE_DISPOSITION_INFO struct { - DeleteFile bool + DeleteFile byte } // https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddk/ns-ntddk-_file_disposition_information type FILE_DISPOSITION_INFORMATION struct { - DeleteFile bool + DeleteFile byte } // https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddk/ns-ntddk-_file_disposition_information_ex @@ -250,7 +250,7 @@ const ( // https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_rename_information type FILE_RENAME_INFORMATION struct { - ReplaceIfExists bool + ReplaceIfExists byte RootDirectory syscall.Handle FileNameLength uint32 FileName [syscall.MAX_PATH]uint16 @@ -266,7 +266,7 @@ type FILE_RENAME_INFORMATION_EX struct { // https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_link_information type FILE_LINK_INFORMATION struct { - ReplaceIfExists bool + ReplaceIfExists byte RootDirectory syscall.Handle FileNameLength uint32 FileName [syscall.MAX_PATH]uint16