Driver: Minor refactor

This commit is contained in:
Nodir Temirkhodjaev 2023-04-14 12:03:37 +03:00
parent edf0ae45d8
commit af927793b2
4 changed files with 7 additions and 11 deletions

View File

@ -59,10 +59,8 @@ static PFORT_CONF_EXE_NODE fort_conf_ref_exe_find_node(
(PFORT_CONF_EXE_NODE) tommy_hashdyn_bucket(&conf_ref->exe_map, path_hash);
while (node != NULL) {
if (node->path_hash == path_hash
&& fort_conf_app_exe_equal(node->app_entry, path, path_len)) {
if (fort_conf_app_exe_equal(node->app_entry, path, path_len))
return node;
}
node = node->next;
}

View File

@ -953,16 +953,15 @@ FORT_API void NTAPI fort_callout_timer(void)
PFORT_BUFFER buf = &fort_device()->buffer;
PFORT_STAT stat = &fort_device()->stat;
KLOCK_QUEUE_HANDLE buf_lock_queue;
KLOCK_QUEUE_HANDLE stat_lock_queue;
PIRP irp = NULL;
ULONG_PTR info;
/* Lock buffer */
KLOCK_QUEUE_HANDLE buf_lock_queue;
fort_buffer_dpc_begin(buf, &buf_lock_queue);
/* Lock stat */
KLOCK_QUEUE_HANDLE stat_lock_queue;
fort_stat_dpc_begin(stat, &stat_lock_queue);
/* Get current Unix time */

View File

@ -470,9 +470,8 @@ static PFORT_PSNODE fort_pstree_find_proc_hash(
PFORT_PSNODE node = (PFORT_PSNODE) tommy_hashdyn_bucket(&ps_tree->procs_map, pid_hash);
while (node != NULL) {
if (node->process_id == processId) {
if (node->process_id == processId)
return node;
}
node = node->next;
}

View File

@ -51,7 +51,7 @@ static PFORT_STAT_PROC fort_stat_proc_get(PFORT_STAT stat, UINT32 process_id, to
PFORT_STAT_PROC proc = (PFORT_STAT_PROC) tommy_hashdyn_bucket(&stat->procs_map, proc_hash);
while (proc != NULL) {
if (proc->proc_hash == proc_hash && proc->process_id == process_id)
if (proc->process_id == process_id)
return proc;
proc = proc->next;
@ -276,7 +276,7 @@ static PFORT_FLOW fort_flow_get(PFORT_STAT stat, UINT64 flow_id, tommy_key_t flo
PFORT_FLOW flow = (PFORT_FLOW) tommy_hashdyn_bucket(&stat->flows_map, flow_hash);
while (flow != NULL) {
if (flow->flow_hash == flow_hash && flow->flow_id == flow_id)
if (flow->flow_id == flow_id)
return flow;
flow = flow->next;
@ -404,7 +404,7 @@ FORT_API void fort_stat_close_flows(PFORT_STAT stat)
if ((old_stat_flags & FORT_STAT_CLOSED) == 0) {
fort_stat_flags_set(stat, FORT_STAT_CLOSED, TRUE);
InterlockedAdd(&stat->flow_closing_count, (LONG) stat->flows_map.count);
InterlockedAdd(&stat->flow_closing_count, (LONG) tommy_hashdyn_count(&stat->flows_map));
}
}
KeReleaseInStackQueuedSpinLock(&lock_queue);