Skip to content

Commit 8406ca5

Browse files
authored
Merge pull request #1477 from SteveL-MSFT/copilot-fixes
Enhance variant use in firewall
2 parents 1be088c + 9fff498 commit 8406ca5

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

resources/windows_firewall/src/firewall.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl SafeVariant {
2121
Self(VARIANT::default())
2222
}
2323

24-
fn as_mut_ptr(&mut self) -> *mut VARIANT {
24+
fn as_mut(&mut self) -> &mut VARIANT {
2525
&mut self.0
2626
}
2727

@@ -33,7 +33,7 @@ impl SafeVariant {
3333
impl Drop for SafeVariant {
3434
fn drop(&mut self) {
3535
if let Err(e) = unsafe { VariantClear(&mut self.0) } {
36-
crate::write_error(&format!("Warning: VariantClear failed with HRESULT: {:#010x}", e.code().0));
36+
crate::write_error(&format!("Warning: VariantClear failed with HRESULT: {:#010x}", e.code().0 as u32));
3737
}
3838
}
3939
}
@@ -81,8 +81,7 @@ impl FirewallStore {
8181
loop {
8282
let mut fetched = 0u32;
8383
let mut safe_variant = SafeVariant::new();
84-
let variant_slice = unsafe { std::slice::from_raw_parts_mut(safe_variant.as_mut_ptr(), 1) };
85-
let hr = unsafe { enum_variant.Next(variant_slice, &mut fetched) };
84+
let hr = unsafe { enum_variant.Next(std::slice::from_mut(safe_variant.as_mut()), &mut fetched) };
8685
if hr == S_FALSE || fetched == 0 {
8786
break;
8887
}

0 commit comments

Comments
 (0)