From 4d90c65d54540cf5cacf46e4a496e08c0cb28092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Fri, 16 Jun 2017 20:59:15 +0000 Subject: [PATCH] [NTOS]: Few improvements: - Remove few unneeded PCMHIVE "backwards"-casts, and in particular the 1st parameter of CmpUnlinkHiveFromMaster(). - Improve the dprints in CmCountOpenSubKeys(). svn path=/trunk/; revision=75064 --- reactos/ntoskrnl/config/cmapi.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/reactos/ntoskrnl/config/cmapi.c b/reactos/ntoskrnl/config/cmapi.c index 62f153e3f7b..54a74ffd4ec 100644 --- a/reactos/ntoskrnl/config/cmapi.c +++ b/reactos/ntoskrnl/config/cmapi.c @@ -1967,7 +1967,7 @@ CmFlushKey(IN PCM_KEY_CONTROL_BLOCK Kcb, } /* Release the flush lock */ - CmpUnlockHiveFlusher((PCMHIVE)Hive); + CmpUnlockHiveFlusher(CmHive); } /* Return the status */ @@ -2130,7 +2130,7 @@ CmLoadKey(IN POBJECT_ATTRIBUTES TargetKey, static BOOLEAN NTAPI -CmpUnlinkHiveFromMaster(IN PHHIVE Hive, +CmpUnlinkHiveFromMaster(IN PCMHIVE CmHive, IN HCELL_INDEX Cell) { PCELL_DATA CellData; @@ -2140,13 +2140,13 @@ CmpUnlinkHiveFromMaster(IN PHHIVE Hive, DPRINT("CmpUnlinkHiveFromMaster()\n"); /* Get the cell data */ - CellData = HvGetCell(Hive, Cell); + CellData = HvGetCell(&CmHive->Hive, Cell); if (CellData == NULL) return FALSE; /* Get the link cell and release the current cell */ LinkCell = CellData->u.KeyNode.Parent; - HvReleaseCell(Hive, Cell); + HvReleaseCell(&CmHive->Hive, Cell); /* Remove the link cell from the master hive */ CmpLockHiveFlusherExclusive(CmiVolatileHive); @@ -2160,13 +2160,9 @@ CmpUnlinkHiveFromMaster(IN PHHIVE Hive, return FALSE; } - /* Lock the hive list */ + /* Remove the hive from the list */ ExAcquirePushLockExclusive(&CmpHiveListHeadLock); - - /* Remove this hive */ - RemoveEntryList(&((PCMHIVE)Hive)->HiveList); - - /* Release the lock */ + RemoveEntryList(&CmHive->HiveList); ExReleasePushLock(&CmpHiveListHeadLock); return TRUE; @@ -2206,7 +2202,7 @@ CmUnloadKey(IN PCM_KEY_CONTROL_BLOCK Kcb, CmFlushKey(Kcb, TRUE); /* Unlink the hive from the master hive */ - if (!CmpUnlinkHiveFromMaster(Hive, Cell)) + if (!CmpUnlinkHiveFromMaster(CmHive, Cell)) { DPRINT("CmpUnlinkHiveFromMaster() failed!\n"); @@ -2280,7 +2276,7 @@ CmCountOpenSubKeys(IN PCM_KEY_CONTROL_BLOCK RootKcb, /* The root key is the only referenced key. There are no refereced sub keys. */ if (RootKcb->RefCount == 1) { - DPRINT("open sub keys: 0\n"); + DPRINT("Open sub keys: 0\n"); return 0; } @@ -2312,8 +2308,7 @@ CmCountOpenSubKeys(IN PCM_KEY_CONTROL_BLOCK RootKcb, /* Check whether the parent is the root key */ if (ParentKcb == RootKcb) { - DPRINT("Found a sub key \n"); - DPRINT("RefCount = %u\n", CachedKcb->RefCount); + DPRINT("Found a sub key, RefCount = %u\n", CachedKcb->RefCount); if (CachedKcb->RefCount > 0) { @@ -2340,8 +2335,7 @@ CmCountOpenSubKeys(IN PCM_KEY_CONTROL_BLOCK RootKcb, } } - DPRINT("open sub keys: %u\n", SubKeys); - + DPRINT("Open sub keys: %u\n", SubKeys); return SubKeys; }