refactor(zig): Use more std library in zig v0.16#11
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
Summary by CodeRabbit
Walkthrough
ChangesWindows Interop Refactor
Version Bump
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
zig/shim.zig (1)
575-579: ⚡ Quick winSemantic mismatch:
INFINITEis a timeout constant, not a file-size error indicator.
GetFileSizereturnsINVALID_FILE_SIZE(0xFFFFFFFF) on error, which happens to equalINFINITE. While numerically correct, usingINFINITEhere is misleading—readers may assume this relates to waiting. Consider defining a separateINVALID_FILE_SIZEconstant or usingstd.math.maxInt(DWORD)inline with a comment.♻️ Suggested clarification
+const INVALID_FILE_SIZE: DWORD = std.math.maxInt(DWORD); + // ... later in getShimInfo: const file_size = GetFileSize(file_handle, null); - if (file_size == INFINITE) { + if (file_size == INVALID_FILE_SIZE) { writeError("Cannot get shim file size.\n");
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
zig/shim.zig (1)
81-89:⚠️ Potential issue | 🔴 CriticalFix type mismatch in
CreateFileWcalls — ACCESS_MASK and FILE.SHARE are u32 types, not structs.Lines 223, 227, 231, and 566-573 pass struct literals (
.{ .GENERIC = .{ .READ = true } }and.{ .READ = true }) toCreateFileW, butwindows.ACCESS_MASKandwindows.FILE.SHAREare type aliases for u32 in Zig 0.16's stdlib. These parameters expect bitmask constants likewindows.GENERIC_READ(0x80000000), not struct values. The code will not compile. Use the appropriate u32 bitmask constants instead.
🧹 Nitpick comments (1)
zig/shim.zig (1)
583-587: ⚡ Quick winUse a semantically correct constant for file size error checking.
GetFileSizereturnsINVALID_FILE_SIZE(0xFFFFFFFF) on error, notINFINITE. While both have the same numeric value,INFINITEsemantically represents a timeout sentinel for wait functions. Using it here is misleading.♻️ Suggested fix
+const INVALID_FILE_SIZE: windows.DWORD = 0xFFFFFFFF; + // ... in getShimInfo: const file_size = GetFileSize(file_handle, null); - if (file_size == INFINITE) { + if (file_size == INVALID_FILE_SIZE) { writeError("Cannot get shim file size.\n"); return error.FileReadError; }
Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
niheaven
left a comment
There was a problem hiding this comment.
Approved in CodeRabbit Change Stack

Thanks for adding Zig support for shims. I wanted to contribute a small improvement.
Zig already defines many of these things in
std, including NT internals. In Zig 0.16, a lot of the Windows code transitioned from Win32 APIs to NT APIs where possible, and I believe most of it has already been ported ( ~ 98 -99%).This benefits us because we can reuse Zig’s existing helpers, definitions, and prototypes, which makes the code smaller, cleaner, and easier to maintain.