History

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.

Eliah Kagan committed 1 year ago

Commit 1f3edb51 parent eec407f1 file · +5 −1Browse files

Unified · Split

gix-path/src/env/git/tests.rs+5−1
@@ -181,7 +181,11 @@ mod locations { · 180 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t