[NTOS:KE][NDK] Minor enhancements to the KeFindConfiguration*Entry() routines (#8720)

- Update the SAL annotations;
- Simplify some while-loops into for-loops.
This commit is contained in:
Hermès Bélusca-Maïto
2026-01-18 21:51:36 +01:00
parent 3ac86990e3
commit e05e6c4849
2 changed files with 45 additions and 48 deletions

View File

@@ -1,16 +1,13 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ke/config.c
* PURPOSE: Configuration Tree Routines
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
* PROJECT: ReactOS Kernel
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Configuration Tree Routines
* COPYRIGHT: Copyright 2005-2006 Alex Ionescu <alex.ionescu@reactos.org>
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
/* FUNCTIONS *****************************************************************/
@@ -19,31 +16,12 @@
*/
PCONFIGURATION_COMPONENT_DATA
NTAPI
KeFindConfigurationEntry(IN PCONFIGURATION_COMPONENT_DATA Child,
IN CONFIGURATION_CLASS Class,
IN CONFIGURATION_TYPE Type,
IN PULONG ComponentKey OPTIONAL)
{
PCONFIGURATION_COMPONENT_DATA NextLink = NULL;
/* Start Search at Root */
return KeFindConfigurationNextEntry(Child,
Class,
Type,
ComponentKey,
&NextLink);
}
/*
* @implemented
*/
PCONFIGURATION_COMPONENT_DATA
NTAPI
KeFindConfigurationNextEntry(IN PCONFIGURATION_COMPONENT_DATA Child,
IN CONFIGURATION_CLASS Class,
IN CONFIGURATION_TYPE Type,
IN PULONG ComponentKey OPTIONAL,
IN PCONFIGURATION_COMPONENT_DATA *NextLink)
KeFindConfigurationNextEntry(
_In_ PCONFIGURATION_COMPONENT_DATA Child,
_In_ CONFIGURATION_CLASS Class,
_In_ CONFIGURATION_TYPE Type,
_In_opt_ PULONG ComponentKey,
_Inout_ PCONFIGURATION_COMPONENT_DATA *NextLink)
{
ULONG Key = 0;
ULONG Mask = 0;
@@ -57,14 +35,15 @@ KeFindConfigurationNextEntry(IN PCONFIGURATION_COMPONENT_DATA Child,
Mask = -1;
}
/* Loop the Components until we find a a match */
while (Child)
/* Loop the components until we find a a match */
for (; Child; Child = Child->Child)
{
/* Check if we are starting somewhere already */
if (*NextLink)
{
/* If we've found the place where we started, clear and continue */
if (Child == *NextLink) *NextLink = NULL;
if (Child == *NextLink)
*NextLink = NULL;
}
else
{
@@ -79,14 +58,14 @@ KeFindConfigurationNextEntry(IN PCONFIGURATION_COMPONENT_DATA Child,
}
/* Now we've also got to lookup the siblings */
Sibling = Child->Sibling;
while (Sibling)
for (Sibling = Child->Sibling; Sibling; Sibling = Sibling->Sibling)
{
/* Check if we are starting somewhere already */
if (*NextLink)
{
/* If we've found the place where we started, clear and continue */
if (Sibling == *NextLink) *NextLink = NULL;
if (Sibling == *NextLink)
*NextLink = NULL;
}
else
{
@@ -100,7 +79,7 @@ KeFindConfigurationNextEntry(IN PCONFIGURATION_COMPONENT_DATA Child,
}
}
/* We've got to check if the Sibling has a Child as well */
/* We've got to check if the sibling has a child as well */
if (Sibling->Child)
{
/* We're just going to call ourselves again */
@@ -109,17 +88,33 @@ KeFindConfigurationNextEntry(IN PCONFIGURATION_COMPONENT_DATA Child,
Type,
ComponentKey,
NextLink);
if (ReturnEntry) return ReturnEntry;
if (ReturnEntry)
return ReturnEntry;
}
/* Next Sibling */
Sibling = Sibling->Sibling;
}
/* Next Child */
Child = Child->Child;
}
/* If we got here, nothing was found */
return NULL;
}
/*
* @implemented
*/
PCONFIGURATION_COMPONENT_DATA
NTAPI
KeFindConfigurationEntry(
_In_ PCONFIGURATION_COMPONENT_DATA Child,
_In_ CONFIGURATION_CLASS Class,
_In_ CONFIGURATION_TYPE Type,
_In_opt_ PULONG ComponentKey)
{
PCONFIGURATION_COMPONENT_DATA NextLink = NULL;
/* Start search at the root */
return KeFindConfigurationNextEntry(Child,
Class,
Type,
ComponentKey,
&NextLink);
}

View File

@@ -294,9 +294,10 @@ KeSignalCallDpcSynchronize(
);
//
// ARC Configuration Functions. Only enabled if you have ARC Support
// ARC Configuration Functions. Only enabled if you have ARC support.
//
#ifdef _ARC_
NTSYSAPI
PCONFIGURATION_COMPONENT_DATA
NTAPI
KeFindConfigurationNextEntry(
@@ -304,9 +305,10 @@ KeFindConfigurationNextEntry(
_In_ CONFIGURATION_CLASS Class,
_In_ CONFIGURATION_TYPE Type,
_In_opt_ PULONG ComponentKey,
_In_ PCONFIGURATION_COMPONENT_DATA *NextLink
_Inout_ PCONFIGURATION_COMPONENT_DATA *NextLink
);
NTSYSAPI
PCONFIGURATION_COMPONENT_DATA
NTAPI
KeFindConfigurationEntry(