summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2025-03-03 11:07:51 +0100
committerDavid Lönnhager <david.l@mullvad.net>2025-03-05 23:32:38 +0100
commitcc4c66dc386cbeabc270f9d26b939e757175f2cd (patch)
tree62af261e4a731e0b5b5503e6f0810625970b1845
parent9ab1e1012c644203663710b1c00106a63ddfe10d (diff)
downloadmullvadvpn-cc4c66dc386cbeabc270f9d26b939e757175f2cd.tar.xz
mullvadvpn-cc4c66dc386cbeabc270f9d26b939e757175f2cd.zip
Add missing safety comments
-rw-r--r--installer-downloader/src/winapi_impl/ui.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/installer-downloader/src/winapi_impl/ui.rs b/installer-downloader/src/winapi_impl/ui.rs
index a83d2007bc..f788ea4bd2 100644
--- a/installer-downloader/src/winapi_impl/ui.rs
+++ b/installer-downloader/src/winapi_impl/ui.rs
@@ -390,6 +390,7 @@ fn handle_banner_label_colors(
}
if msg == WM_CTLCOLORSTATIC {
+ // SAFETY: `w` is a valid device context for WM_CTLCOLORSTATIC
unsafe {
SetTextColor(w as _, rgb([255, 255, 255]));
SetBkColor(w as _, rgb(BACKGROUND_COLOR));
@@ -413,6 +414,7 @@ fn handle_link_messages(
}
if msg == WM_CTLCOLORSTATIC && Some(p) == link_hwnd {
+ // SAFETY: `w` is a valid device context for WM_CTLCOLORSTATIC
unsafe {
SetBkMode(w as _, TRANSPARENT as _);
SetTextColor(w as _, rgb(LINK_COLOR));
@@ -476,15 +478,15 @@ fn try_pair_into<A: TryInto<B>, B>(a: (A, A)) -> Result<(B, B), A::Error> {
fn create_link_font() -> Result<nwg::Font, nwg::NwgError> {
let face_name = "Segoe UI".encode_utf16();
- let raw_font = unsafe {
- let mut logfont: LOGFONTW = std::mem::zeroed();
- logfont.lfUnderline = 1;
+ // SAFETY: Trivially safe. `LOGFONTW` is a C struct
+ let mut logfont: LOGFONTW = unsafe { std::mem::zeroed() };
+ logfont.lfUnderline = 1;
+ for (dest, src) in logfont.lfFaceName.iter_mut().zip(face_name) {
+ *dest = src;
+ }
- for (dest, src) in logfont.lfFaceName.iter_mut().zip(face_name) {
- *dest = src;
- }
- CreateFontIndirectW(&logfont)
- };
+ // SAFETY: `logfont` is a valid font
+ let raw_font = unsafe { CreateFontIndirectW(&logfont) };
if raw_font == 0 {
return Err(nwg::NwgError::Unknown);