mirror of
https://github.com/safing/portmaster
synced 2025-09-04 11:39:29 +00:00
[windows_kext] Fix some clippy warnings
This commit is contained in:
parent
81bee82b8f
commit
ea59c11d0d
8 changed files with 18 additions and 26 deletions
|
@ -43,8 +43,8 @@ unsafe impl GlobalAlloc for WindowsAllocator {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
|
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
|
||||||
let pool = self.alloc(layout);
|
|
||||||
pool
|
self.alloc(layout)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
|
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
|
||||||
|
|
|
@ -37,9 +37,7 @@ impl ClassifyDefer {
|
||||||
}
|
}
|
||||||
ClassifyDefer::Reauthorization(_callout_id, packet_list) => {
|
ClassifyDefer::Reauthorization(_callout_id, packet_list) => {
|
||||||
// There is no way to reset single filter. If another request for filter reset is trigger at the same time it will fail.
|
// There is no way to reset single filter. If another request for filter reset is trigger at the same time it will fail.
|
||||||
if let Err(err) = filter_engine.reset_all_filters() {
|
filter_engine.reset_all_filters()?;
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
return Ok(packet_list);
|
return Ok(packet_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,9 +113,7 @@ pub(crate) fn register_callout(
|
||||||
|
|
||||||
check_ntstatus(status)?;
|
check_ntstatus(status)?;
|
||||||
|
|
||||||
if let Err(err) = callout_add(filter_engine_handle, guid, layer, name, description) {
|
callout_add(filter_engine_handle, guid, layer, name, description)?;
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(callout_id);
|
return Ok(callout_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,10 +154,10 @@ impl FwpsIncomingMetadataValues {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
enum FwpsDiscardModule0 {
|
enum FwpsDiscardModule0 {
|
||||||
FwpsDiscardModuleNetwork = 0,
|
Network = 0,
|
||||||
FwpsDiscardModuleTransport = 1,
|
Transport = 1,
|
||||||
FwpsDiscardModuleGeneral = 2,
|
General = 2,
|
||||||
FwpsDiscardModuleMax = 3,
|
Max = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
@ -107,9 +107,7 @@ impl FilterEngine {
|
||||||
filter_engine.callouts = Some(boxed_callouts);
|
filter_engine.callouts = Some(boxed_callouts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = filter_engine.commit() {
|
filter_engine.commit()?
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.committed = true;
|
self.committed = true;
|
||||||
info!("transaction committed");
|
info!("transaction committed");
|
||||||
|
@ -147,9 +145,7 @@ impl FilterEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Commit transaction.
|
// Commit transaction.
|
||||||
if let Err(err) = filter_engine.commit() {
|
filter_engine.commit()?;
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl NetBufferList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate space in buffer, if buffer is too small.
|
// Allocate space in buffer, if buffer is too small.
|
||||||
let mut buffer = alloc::vec![0 as u8; data_length as usize];
|
let mut buffer = alloc::vec![0_u8; data_length as usize];
|
||||||
|
|
||||||
let ptr = NdisGetDataBuffer(nb, data_length, buffer.as_mut_ptr(), 1, 0);
|
let ptr = NdisGetDataBuffer(nb, data_length, buffer.as_mut_ptr(), 1, 0);
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ impl Iterator for NetBufferListIter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_packet_partial<'a>(nbl: *mut NET_BUFFER_LIST, buffer: &'a mut [u8]) -> Result<(), ()> {
|
pub fn read_packet_partial(nbl: *mut NET_BUFFER_LIST, buffer: &mut [u8]) -> Result<(), ()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let Some(nbl) = nbl.as_ref() else {
|
let Some(nbl) = nbl.as_ref() else {
|
||||||
return Err(());
|
return Err(());
|
||||||
|
|
|
@ -105,9 +105,9 @@ impl Injector {
|
||||||
}
|
}
|
||||||
let mut remote_ip: [u8; 16] = [0; 16];
|
let mut remote_ip: [u8; 16] = [0; 16];
|
||||||
if ipv6 {
|
if ipv6 {
|
||||||
remote_ip[0..16].copy_from_slice(&remote_ip_slice);
|
remote_ip[0..16].copy_from_slice(remote_ip_slice);
|
||||||
} else {
|
} else {
|
||||||
remote_ip[0..4].copy_from_slice(&remote_ip_slice);
|
remote_ip[0..4].copy_from_slice(remote_ip_slice);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransportPacketList {
|
TransportPacketList {
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl ReadRequest<'_> {
|
||||||
for i in 0..bytes_to_write {
|
for i in 0..bytes_to_write {
|
||||||
self.buffer[self.fill_index + i] = bytes[i];
|
self.buffer[self.fill_index + i] = bytes[i];
|
||||||
}
|
}
|
||||||
self.fill_index = self.fill_index + bytes_to_write;
|
self.fill_index += bytes_to_write;
|
||||||
|
|
||||||
bytes_to_write
|
bytes_to_write
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ impl WriteRequest<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_buffer(&self) -> &[u8] {
|
pub fn get_buffer(&self) -> &[u8] {
|
||||||
&self.buffer
|
self.buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mark_all_as_read(&mut self) {
|
pub fn mark_all_as_read(&mut self) {
|
||||||
|
@ -155,7 +155,7 @@ impl DeviceControlRequest<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_buffer(&self) -> &[u8] {
|
pub fn get_buffer(&self) -> &[u8] {
|
||||||
&self.buffer
|
self.buffer
|
||||||
}
|
}
|
||||||
pub fn write(&mut self, bytes: &[u8]) -> usize {
|
pub fn write(&mut self, bytes: &[u8]) -> usize {
|
||||||
let mut bytes_to_write: usize = bytes.len();
|
let mut bytes_to_write: usize = bytes.len();
|
||||||
|
@ -168,7 +168,7 @@ impl DeviceControlRequest<'_> {
|
||||||
for i in 0..bytes_to_write {
|
for i in 0..bytes_to_write {
|
||||||
self.buffer[self.fill_index + i] = bytes[i];
|
self.buffer[self.fill_index + i] = bytes[i];
|
||||||
}
|
}
|
||||||
self.fill_index = self.fill_index + bytes_to_write;
|
self.fill_index += bytes_to_write;
|
||||||
|
|
||||||
bytes_to_write
|
bytes_to_write
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue