Skip to content

Commit 7abc880

Browse files
CopilotCBenoit
andcommitted
Fix clippy warnings in pedm-simulator and win-api-wrappers account tests
- Add #![allow(clippy::print_stdout)] to pedm-simulator windows.rs module - Fix search_is_some by using any() instead of find().is_some() - Remove unfulfilled cast_sign_loss expectations per AGENTS.md guidelines - Add #[allow(clippy::cast_possible_wrap)] for intentional HRESULT cast - Add #![allow] attributes to account.rs test module Co-authored-by: CBenoit <3809077+CBenoit@users.noreply.github.com>
1 parent 7d239ab commit 7abc880

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

crates/pedm-simulator/src/windows.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::print_stdout)]
2+
13
use anyhow::Context as _;
24
use win_api_wrappers::identity::account::{enumerate_account_rights, get_username, lookup_account_by_name};
35
use win_api_wrappers::identity::sid::{Sid, SidAndAttributes};
@@ -59,8 +61,7 @@ pub(super) fn main() -> anyhow::Result<()> {
5961
.context("list token privileges")?
6062
.as_slice()
6163
.iter()
62-
.find(|privilege| privilege.Luid == se_create_token_name_luid)
63-
.is_some();
64+
.any(|privilege| privilege.Luid == se_create_token_name_luid);
6465

6566
assert!(se_create_token_name_is_enabled);
6667
}
@@ -73,6 +74,7 @@ pub(super) fn main() -> anyhow::Result<()> {
7374
// - This context may not be able to see the same network resources or DC that the interactive user.
7475
// Causing LookupAccountNameW to fail with a "no mapping" error.
7576
// Let’s just go ahead with the elevation in this case, assuming LocalSystem is enough for all intents and purposes at this point.
77+
#[allow(clippy::cast_possible_wrap)]
7678
if e.code() == HRESULT(0x80070534u32 as i32) {
7779
println!("Got the 'no mapping' error; continuing...")
7880
} else {
@@ -95,15 +97,13 @@ pub(super) fn main() -> anyhow::Result<()> {
9597

9698
groups.push(SidAndAttributes {
9799
sid: Sid::from_well_known(Security::WinLocalAccountAndAdministratorSid, None)?,
98-
#[expect(clippy::cast_sign_loss)]
99100
attributes: (SystemServices::SE_GROUP_ENABLED
100101
| SystemServices::SE_GROUP_ENABLED_BY_DEFAULT
101102
| SystemServices::SE_GROUP_MANDATORY) as u32,
102103
});
103104

104105
groups.push(SidAndAttributes {
105106
sid: owner_sid.clone(),
106-
#[expect(clippy::cast_sign_loss)]
107107
attributes: (SystemServices::SE_GROUP_ENABLED
108108
| SystemServices::SE_GROUP_ENABLED_BY_DEFAULT
109109
| SystemServices::SE_GROUP_MANDATORY
@@ -112,7 +112,6 @@ pub(super) fn main() -> anyhow::Result<()> {
112112

113113
groups.push(SidAndAttributes {
114114
sid: Sid::from_well_known(Security::WinHighLabelSid, None)?,
115-
#[expect(clippy::cast_sign_loss)]
116115
attributes: (SystemServices::SE_GROUP_ENABLED
117116
| SystemServices::SE_GROUP_ENABLED_BY_DEFAULT
118117
| SystemServices::SE_GROUP_MANDATORY) as u32,

crates/win-api-wrappers/src/identity/account.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ pub fn enumerate_account_rights(sid: &Sid) -> anyhow::Result<Vec<U16CString>> {
435435

436436
#[cfg(test)]
437437
mod tests {
438+
#![allow(clippy::unwrap_used)]
439+
#![allow(clippy::print_stdout)]
440+
438441
use super::*;
439442

440443
use crate::process::Process;

0 commit comments

Comments
 (0)