clippy-izing an unsafe in pam (#1795)

This commit is contained in:
James Hodgkinson 2023-07-03 11:13:45 +10:00 committed by GitHub
parent 90fe6b7ff2
commit cd7f1781ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 8 deletions

View file

@ -735,6 +735,7 @@ impl Entry<EntryIncremental, EntryNew> {
match (self.attrs.get(attr_name), db_ent.attrs.get(attr_name)) { match (self.attrs.get(attr_name), db_ent.attrs.get(attr_name)) {
(Some(vs_left), Some(vs_right)) if take_left => { (Some(vs_left), Some(vs_right)) if take_left => {
#[allow(clippy::todo)]
if let Some(_attr_state) = vs_left.repl_merge_valueset(vs_right) if let Some(_attr_state) = vs_left.repl_merge_valueset(vs_right)
{ {
todo!(); todo!();
@ -744,6 +745,7 @@ impl Entry<EntryIncremental, EntryNew> {
} }
} }
(Some(vs_left), Some(vs_right)) => { (Some(vs_left), Some(vs_right)) => {
#[allow(clippy::todo)]
if let Some(_attr_state) = vs_right.repl_merge_valueset(vs_left) if let Some(_attr_state) = vs_right.repl_merge_valueset(vs_left)
{ {
todo!(); todo!();
@ -907,6 +909,7 @@ impl Entry<EntryIncremental, EntryCommitted> {
attrs: self.attrs, attrs: self.attrs,
}; };
#[allow(clippy::todo)]
if let Err(e) = ne.validate(schema) { if let Err(e) = ne.validate(schema) {
warn!(uuid = ?self.valid.uuid, err = ?e, "Entry failed schema check, moving to a conflict state"); warn!(uuid = ?self.valid.uuid, err = ?e, "Entry failed schema check, moving to a conflict state");
ne.add_ava_int("class", Value::new_class("conflict")); ne.add_ava_int("class", Value::new_class("conflict"));

View file

@ -4,7 +4,9 @@
#![deny(warnings)] #![deny(warnings)]
#![recursion_limit = "512"] #![recursion_limit = "512"]
#![warn(unused_extern_crates)] #![warn(unused_extern_crates)]
#![deny(clippy::todo)] // TODO: can't use this until we have a better way to handle the 'todo' lint?
// #![deny(clippy::todo)]
#![warn(clippy::todo)]
#![deny(clippy::unimplemented)] #![deny(clippy::unimplemented)]
#![deny(clippy::unwrap_used)] #![deny(clippy::unwrap_used)]
#![deny(clippy::expect_used)] #![deny(clippy::expect_used)]

View file

@ -69,6 +69,8 @@ impl<'a> QueryServerWriteTransaction<'a> {
// /- entries that need to be created as conflicts. // /- entries that need to be created as conflicts.
// | /- entries that survive and need update to the db in place. // | /- entries that survive and need update to the db in place.
// v v // v v
#[allow(clippy::todo)]
let (conflict_create, conflict_update): ( let (conflict_create, conflict_update): (
Vec<EntrySealedNew>, Vec<EntrySealedNew>,
Vec<(EntryIncrementalCommitted, Arc<EntrySealedCommitted>)>, Vec<(EntryIncrementalCommitted, Arc<EntrySealedCommitted>)>,
@ -217,6 +219,7 @@ impl<'a> QueryServerWriteTransaction<'a> {
error!("This server's content must be refreshed to proceed. If you have configured automatic refresh, this will occur shortly."); error!("This server's content must be refreshed to proceed. If you have configured automatic refresh, this will occur shortly.");
Ok(ConsumerState::RefreshRequired) Ok(ConsumerState::RefreshRequired)
} }
#[allow(clippy::todo)]
ReplIncrementalContext::UnwillingToSupply => { ReplIncrementalContext::UnwillingToSupply => {
todo!(); todo!();
} }

View file

@ -498,6 +498,7 @@ impl ValueSetT for ValueSetSession {
Ok(Box::new(ValueSetApiToken { map })) Ok(Box::new(ValueSetApiToken { map }))
} }
#[allow(clippy::todo)]
fn repl_merge_valueset(&self, _older: &ValueSet) -> Option<ValueSet> { fn repl_merge_valueset(&self, _older: &ValueSet) -> Option<ValueSet> {
todo!(); todo!();
} }
@ -872,6 +873,7 @@ impl ValueSetT for ValueSetOauth2Session {
Some(Box::new(self.map.values().map(|m| &m.rs_uuid).copied())) Some(Box::new(self.map.values().map(|m| &m.rs_uuid).copied()))
} }
#[allow(clippy::todo)]
fn repl_merge_valueset(&self, _older: &ValueSet) -> Option<ValueSet> { fn repl_merge_valueset(&self, _older: &ValueSet) -> Option<ValueSet> {
todo!(); todo!();
} }

View file

@ -33,7 +33,7 @@ extern "C" {
pamh: *const PamHandle, pamh: *const PamHandle,
module_data_name: *const c_char, module_data_name: *const c_char,
data: *mut PamDataT, data: *mut PamDataT,
cleanup: extern "C" fn( cleanup: unsafe extern "C" fn(
pamh: *const PamHandle, pamh: *const PamHandle,
data: *mut PamDataT, data: *mut PamDataT,
error_status: PamResultCode, error_status: PamResultCode,
@ -56,13 +56,14 @@ extern "C" {
) -> PamResultCode; ) -> PamResultCode;
} }
pub extern "C" fn cleanup<T>(_: *const PamHandle, c_data: *mut PamDataT, _: PamResultCode) { /// # Safety
unsafe { ///
/// We're doing what we can for this one, but it's FFI.
pub unsafe extern "C" fn cleanup<T>(_: *const PamHandle, c_data: *mut PamDataT, _: PamResultCode) {
let c_data = Box::from_raw(c_data); let c_data = Box::from_raw(c_data);
let data: Box<T> = mem::transmute(c_data); let data: Box<T> = mem::transmute(c_data);
mem::drop(data); mem::drop(data);
} }
}
pub type PamResult<T> = Result<T, PamResultCode>; pub type PamResult<T> = Result<T, PamResultCode>;