Skip to content

Commit 1f3edb5

Browse files
committed
Add a "SAFETY:" comment in PlatformBitness::current()
The `GetCurrentProcess` and `IsWow64Process` Windows API calls (mediated through the `windows` crate) are pretty straightforward, and this code is only in the test suite, not in production. Still, it's probably best to have a "SAFETY:" comment where `unsafe` code is used. This adds such a comment, covering those two calls.
1 parent eec407f commit 1f3edb5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gix-path/src/env/git/tests.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ mod locations {
181181
// is for the test suite, and doing it this way allows problems to be caught earlier if
182182
// a change made on a 64-bit development machine breaks the IsWow64Process() call.
183183
let mut wow64process = BOOL::default();
184-
unsafe { IsWow64Process(GetCurrentProcess(), &mut wow64process)? };
184+
unsafe {
185+
// SAFETY: `GetCurrentProcess` always succeeds, and the handle it returns is a
186+
// valid process handle to pass to `IsWow64Process`.
187+
IsWow64Process(GetCurrentProcess(), &mut wow64process)?;
188+
}
185189

186190
let platform_bitness = if wow64process.as_bool() {
187191
Self::Is32on64

0 commit comments

Comments
 (0)