https://git.reactos.org/?p=reactos.git;a=commitdiff;h=76f1da5631489642fe1c8201ce2bd6afc8f32fb0

commit 76f1da5631489642fe1c8201ce2bd6afc8f32fb0
Author:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
AuthorDate: Wed Dec 20 20:28:13 2023 +0100
Commit:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
CommitDate: Wed Jan 17 22:09:37 2024 +0100

    [NTOS:CM][CMLIB] Minor code styling
    
    In particular remove some extra-parentheses around single code tokens,
    and replace few "DPRINT1 + while (TRUE);" by UNIMPLEMENTED_DBGBREAK.
    
    + Improve some comments.
---
 ntoskrnl/config/cmapi.c    | 33 ++++++++++++++---------------
 ntoskrnl/config/cmcontrl.c |  3 +--
 ntoskrnl/config/cminit.c   | 22 ++++++++++----------
 ntoskrnl/config/cmkcbncb.c | 18 ++++++++--------
 ntoskrnl/config/cmlazy.c   | 12 +++++------
 ntoskrnl/config/cmparse.c  | 14 ++++++-------
 ntoskrnl/config/cmse.c     |  2 +-
 ntoskrnl/config/cmsysini.c | 20 +++++++++---------
 ntoskrnl/config/cmvalche.c | 20 +++++++++---------
 ntoskrnl/config/ntapi.c    | 14 ++++++-------
 sdk/lib/cmlib/hivewrt.c    | 52 ++++++++++++++++++++++------------------------
 11 files changed, 103 insertions(+), 107 deletions(-)

diff --git a/ntoskrnl/config/cmapi.c b/ntoskrnl/config/cmapi.c
index 8e3e3edd69a..4d4edfde77a 100644
--- a/ntoskrnl/config/cmapi.c
+++ b/ntoskrnl/config/cmapi.c
@@ -67,8 +67,7 @@ CmpIsHiveAlreadyLoaded(IN HANDLE KeyHandle,
         if (Hive->Frozen)
         {
             /* FIXME: TODO */
-            DPRINT1("ERROR: Hive is frozen\n");
-            while (TRUE);
+            UNIMPLEMENTED_DBGBREAK("ERROR: Hive is frozen\n");
         }
      }
 
@@ -105,22 +104,22 @@ CmpDoFlushAll(IN BOOLEAN ForceFlush)
             CmpLockHiveFlusherExclusive(Hive);
 
             /* Check for illegal state */
-            if ((ForceFlush) && (Hive->UseCount))
+            if (ForceFlush && Hive->UseCount)
             {
                 /* Registry needs to be locked down */
                 CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK();
-                DPRINT1("FIXME: Hive is damaged and needs fixup\n");
-                while (TRUE);
+                UNIMPLEMENTED_DBGBREAK("FIXME: Hive is damaged and needs 
fixup\n");
             }
 
             /* Only sync if we are forced to or if it won't cause a hive 
shrink */
-            if ((ForceFlush) || (!HvHiveWillShrink(&Hive->Hive)))
+            if (ForceFlush || !HvHiveWillShrink(&Hive->Hive))
             {
                 /* Do the sync */
                 Status = HvSyncHive(&Hive->Hive);
 
                 /* If something failed - set the flag and continue looping */
-                if (!NT_SUCCESS(Status)) Result = FALSE;
+                if (!NT_SUCCESS(Status))
+                    Result = FALSE;
             }
             else
             {
@@ -708,8 +707,8 @@ DoAgain:
         }
 
         /* We need the exclusive KCB lock now */
-        if (!(CmpIsKcbLockedExclusive(Kcb)) &&
-            !(CmpTryToConvertKcbSharedToExclusive(Kcb)))
+        if (!CmpIsKcbLockedExclusive(Kcb) &&
+            !CmpTryToConvertKcbSharedToExclusive(Kcb))
         {
             /* Acquire exclusive lock */
             CmpConvertKcbSharedToExclusive(Kcb);
@@ -873,7 +872,7 @@ DoAgain:
         Kcb->KcbLastWriteTime = Parent->LastWriteTime;
 
         /* Check if the cell is cached */
-        if ((Found) && (CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList)))
+        if (Found && CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList))
         {
             /* Shouldn't happen */
             ASSERT(FALSE);
@@ -884,7 +883,7 @@ DoAgain:
             CmpCleanUpKcbValueCache(Kcb);
 
             /* Sanity checks */
-            ASSERT(!(CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList)));
+            ASSERT(!CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList));
             ASSERT(!(Kcb->ExtFlags & CM_KCB_SYM_LINK_FOUND));
 
             /* Set the value cache */
@@ -901,8 +900,8 @@ DoAgain:
 
     /* Release the cells */
 Quickie:
-    if ((ParentCell != HCELL_NIL) && (Hive)) HvReleaseCell(Hive, ParentCell);
-    if ((ChildCell != HCELL_NIL) && (Hive)) HvReleaseCell(Hive, ChildCell);
+    if ((ParentCell != HCELL_NIL) && Hive) HvReleaseCell(Hive, ParentCell);
+    if ((ChildCell != HCELL_NIL) && Hive) HvReleaseCell(Hive, ChildCell);
 
     /* Release the locks */
     if (FlusherLocked) CmpUnlockHiveFlusher((PCMHIVE)Hive);
@@ -972,9 +971,9 @@ CmDeleteValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
         if (ChildCell == HCELL_NIL) goto Quickie;
 
         /* We found the value, mark all relevant cells dirty */
-        if (!((HvMarkCellDirty(Hive, Cell, FALSE)) &&
-              (HvMarkCellDirty(Hive, Parent->ValueList.List, FALSE)) &&
-              (HvMarkCellDirty(Hive, ChildCell, FALSE))))
+        if (!(HvMarkCellDirty(Hive, Cell, FALSE) &&
+              HvMarkCellDirty(Hive, Parent->ValueList.List, FALSE) &&
+              HvMarkCellDirty(Hive, ChildCell, FALSE)))
         {
             /* Not enough log space, fail */
             Status = STATUS_NO_LOG_SPACE;
@@ -1037,7 +1036,7 @@ CmDeleteValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
         CmpCleanUpKcbValueCache(Kcb);
 
         /* Sanity checks */
-        ASSERT(!(CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList)));
+        ASSERT(!CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList));
         ASSERT(!(Kcb->ExtFlags & CM_KCB_SYM_LINK_FOUND));
 
         /* Set the value cache */
diff --git a/ntoskrnl/config/cmcontrl.c b/ntoskrnl/config/cmcontrl.c
index fdce4c9ab6d..07f65dcea97 100644
--- a/ntoskrnl/config/cmcontrl.c
+++ b/ntoskrnl/config/cmcontrl.c
@@ -208,8 +208,7 @@ CmGetSystemControlValues(IN PVOID SystemHiveData,
                     }
 
                     /* Sanity check if this is a small key */
-                    ASSERT((IsSmallKey ?
-                           (Length <= CM_KEY_VALUE_SMALL) : TRUE));
+                    ASSERT(IsSmallKey ? (Length <= CM_KEY_VALUE_SMALL) : TRUE);
 
                     /* Copy the data in the buffer */
                     RtlCopyMemory(ControlVector->Buffer, Buffer, Length);
diff --git a/ntoskrnl/config/cminit.c b/ntoskrnl/config/cminit.c
index 15dc4f0d77c..5bee7e5a526 100644
--- a/ntoskrnl/config/cminit.c
+++ b/ntoskrnl/config/cminit.c
@@ -49,14 +49,14 @@ CmpInitializeHive(
      * - An alternate hive that is not linked to a correct file type.
      * - A lonely alternate hive not backed up with its corresponding primary 
hive.
      */
-    if (((External) && ((Primary) || (Log))) ||
-        ((Log) && !(Primary)) ||
-        (!(CmpShareSystemHives) && (HiveFlags & HIVE_VOLATILE) &&
-            ((Primary) || (External) || (Log))) ||
-        ((OperationType == HINIT_MEMORY) && (!HiveData)) ||
-        ((Log) && (FileType != HFILE_TYPE_LOG)) ||
-        ((Alternate) && (FileType != HFILE_TYPE_ALTERNATE)) ||
-        ((Alternate) && !(Primary)))
+    if ((External && (Primary || Log)) ||
+        (Log && !Primary) ||
+        (!CmpShareSystemHives && (HiveFlags & HIVE_VOLATILE) &&
+            (Primary || External || Log)) ||
+        ((OperationType == HINIT_MEMORY) && !HiveData) ||
+        (Log && (FileType != HFILE_TYPE_LOG)) ||
+        (Alternate && (FileType != HFILE_TYPE_ALTERNATE)) ||
+        (Alternate && !Primary))
     {
         /* Fail the request */
         return STATUS_INVALID_PARAMETER;
@@ -338,7 +338,7 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
                                NULL);
 
     /* Check if we can create the hive */
-    if ((CreateAllowed) && !(CmpShareSystemHives))
+    if (CreateAllowed && !CmpShareSystemHives)
     {
         /* Open only or create */
         CreateDisposition = FILE_OPEN_IF;
@@ -357,7 +357,7 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
               (NoBuffering ? FILE_NO_INTERMEDIATE_BUFFERING : 0);
 
     /* Set share and access modes */
-    if ((CmpMiniNTBoot) && (CmpShareSystemHives))
+    if (CmpMiniNTBoot && CmpShareSystemHives)
     {
         /* We're on Live CD or otherwise sharing */
         DesiredAccess = FILE_READ_DATA;
@@ -568,7 +568,7 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
                           FILE_SYNCHRONOUS_IO_NONALERT | IoFlags,
                           NULL,
                           0);
-    if ((NT_SUCCESS(Status)) && (MarkAsSystemHive))
+    if (NT_SUCCESS(Status) && MarkAsSystemHive)
     {
         /* We opened it, mark it as a system hive */
         Status = ZwFsControlFile(*Log,
diff --git a/ntoskrnl/config/cmkcbncb.c b/ntoskrnl/config/cmkcbncb.c
index b7b7b0ef9cb..4f70ad91778 100644
--- a/ntoskrnl/config/cmkcbncb.c
+++ b/ntoskrnl/config/cmkcbncb.c
@@ -619,11 +619,11 @@ CmpDereferenceKeyControlBlockWithLock(IN 
PCM_KEY_CONTROL_BLOCK Kcb,
         CMP_ASSERT_KCB_LOCK(Kcb);
 
         /* Check if we should do a direct delete */
-        if (((CmpHoldLazyFlush) &&
+        if ((CmpHoldLazyFlush &&
              !(Kcb->ExtFlags & CM_KCB_SYM_LINK_FOUND) &&
              !(Kcb->Flags & KEY_SYM_LINK)) ||
             (Kcb->ExtFlags & CM_KCB_NO_DELAY_CLOSE) ||
-            (Kcb->Delete))
+             Kcb->Delete)
         {
             /* Clean up the KCB*/
             CmpCleanUpKcbCacheWithLock(Kcb, LockHeldExclusively);
@@ -683,7 +683,7 @@ CmpCreateKeyControlBlock(IN PHHIVE Hive,
     NodeName = *KeyName;
 
     /* Remove leading slash */
-    while ((NodeName.Length) && (*NodeName.Buffer == OBJ_NAME_PATH_SEPARATOR))
+    while (NodeName.Length && (*NodeName.Buffer == OBJ_NAME_PATH_SEPARATOR))
     {
         /* Move the buffer by one */
         NodeName.Buffer++;
@@ -764,7 +764,7 @@ CmpCreateKeyControlBlock(IN PHHIVE Hive,
         else
         {
             /* Check if we're not creating a fake one, but it used to be fake 
*/
-            if ((Kcb->ExtFlags & CM_KCB_KEY_NON_EXIST) && !(IsFake))
+            if ((Kcb->ExtFlags & CM_KCB_KEY_NON_EXIST) && !IsFake)
             {
                 /* Set the hive and cell */
                 Kcb->KeyHive = Hive;
@@ -801,7 +801,7 @@ CmpCreateKeyControlBlock(IN PHHIVE Hive,
         {
             /* Reference the parent */
             if (((Parent->TotalLevels + 1) < 512) &&
-                (CmpReferenceKeyControlBlock(Parent)))
+                CmpReferenceKeyControlBlock(Parent))
             {
                 /* Link it */
                 Kcb->ParentKcb = Parent;
@@ -863,14 +863,14 @@ CmpCreateKeyControlBlock(IN PHHIVE Hive,
     }
 
     /* Check if this is a KCB inside a frozen hive */
-    if ((Kcb) && (((PCMHIVE)Hive)->Frozen) && (!(Kcb->Flags & KEY_SYM_LINK)))
+    if (Kcb && ((PCMHIVE)Hive)->Frozen && !(Kcb->Flags & KEY_SYM_LINK))
     {
         /* Don't add these to the delay close */
         Kcb->ExtFlags |= CM_KCB_NO_DELAY_CLOSE;
     }
 
     /* Sanity check */
-    ASSERT((!Kcb) || (Kcb->Delete == FALSE));
+    ASSERT(!Kcb || !Kcb->Delete);
 
     /* Check if we had locked the hashes */
     if (!HashLock)
@@ -950,7 +950,7 @@ CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
         /* Sanity checks for deleted and fake keys */
         if ((!MyKcb->KeyCell && !MyKcb->Delete) ||
             !MyKcb->KeyHive ||
-            MyKcb->ExtFlags & CM_KCB_KEY_NON_EXIST)
+            (MyKcb->ExtFlags & CM_KCB_KEY_NON_EXIST))
         {
             /* Failure */
             CmpFree(KeyName, 0);
@@ -1109,7 +1109,7 @@ DelistKeyBodyFromKCB(IN PCM_KEY_BODY KeyBody,
     for (i = 0; i < 4; i++)
     {
         /* Add it into the list */
-        if 
(InterlockedCompareExchangePointer((VOID*)&KeyBody->KeyControlBlock->
+        if 
(InterlockedCompareExchangePointer((PVOID*)&KeyBody->KeyControlBlock->
                                               KeyBodyArray[i],
                                               NULL,
                                               KeyBody) == KeyBody)
diff --git a/ntoskrnl/config/cmlazy.c b/ntoskrnl/config/cmlazy.c
index ed03247a8c7..6c128cb3954 100644
--- a/ntoskrnl/config/cmlazy.c
+++ b/ntoskrnl/config/cmlazy.c
@@ -92,9 +92,9 @@ CmpDoFlushNextHive(_In_  BOOLEAN ForceFlush,
                 CmHive->FlushCount = CmpLazyFlushCount;
             }
         }
-        else if ((CmHive->Hive.DirtyCount) &&
-                 (!(CmHive->Hive.HiveFlags & HIVE_VOLATILE)) &&
-                 (!(CmHive->Hive.HiveFlags & HIVE_NOLAZYFLUSH)))
+        else if (CmHive->Hive.DirtyCount &&
+                 !(CmHive->Hive.HiveFlags & HIVE_VOLATILE) &&
+                 !(CmHive->Hive.HiveFlags & HIVE_NOLAZYFLUSH))
         {
             /* Use another lazy flusher for this hive */
             ASSERT(CmHive->FlushCount == CmpLazyFlushCount);
@@ -145,7 +145,7 @@ CmpLazyFlushDpcRoutine(IN PKDPC Dpc,
 {
     /* Check if we should queue the lazy flush worker */
     DPRINT("Flush pending: %s, Holding lazy flush: %s.\n", CmpLazyFlushPending 
? "yes" : "no", CmpHoldLazyFlush ? "yes" : "no");
-    if ((!CmpLazyFlushPending) && (!CmpHoldLazyFlush))
+    if (!CmpLazyFlushPending && !CmpHoldLazyFlush)
     {
         CmpLazyFlushPending = TRUE;
         ExQueueWorkItem(&CmpLazyWorkItem, DelayedWorkQueue);
@@ -160,7 +160,7 @@ CmpLazyFlush(VOID)
     PAGED_CODE();
 
     /* Check if we should set the lazy flush timer */
-    if ((!CmpNoWrite) && (!CmpHoldLazyFlush))
+    if (!CmpNoWrite && !CmpHoldLazyFlush)
     {
         /* Do it */
         DueTime.QuadPart = Int32x32To64(CmpLazyFlushIntervalInSeconds,
@@ -400,7 +400,7 @@ CmpCmdHiveOpen(IN POBJECT_ATTRIBUTES FileAttributes,
          (Status == STATUS_ACCOUNT_EXPIRED) ||
          (Status == STATUS_ACCOUNT_DISABLED) ||
          (Status == STATUS_ACCOUNT_RESTRICTION)) &&
-        (ImpersonationContext))
+        ImpersonationContext)
     {
         /* We failed due to an account/security error, impersonate SYSTEM */
         Status = SeImpersonateClientEx(ImpersonationContext, NULL);
diff --git a/ntoskrnl/config/cmparse.c b/ntoskrnl/config/cmparse.c
index b9bc5c7e596..db2ec0e9705 100644
--- a/ntoskrnl/config/cmparse.c
+++ b/ntoskrnl/config/cmparse.c
@@ -39,7 +39,7 @@ CmpGetNextName(IN OUT PUNICODE_STRING RemainingName,
     }
 
     /* Check if we have a path separator */
-    while ((RemainingName->Length) &&
+    while (RemainingName->Length &&
            (*RemainingName->Buffer == OBJ_NAME_PATH_SEPARATOR))
     {
         /* Skip it */
@@ -50,7 +50,7 @@ CmpGetNextName(IN OUT PUNICODE_STRING RemainingName,
 
     /* Start loop at where the current buffer is */
     NextName->Buffer = RemainingName->Buffer;
-    while ((RemainingName->Length) &&
+    while (RemainingName->Length &&
            (*RemainingName->Buffer != OBJ_NAME_PATH_SEPARATOR))
     {
         /* Move to the next character */
@@ -1873,7 +1873,7 @@ CmpParseKey(IN PVOID ParseObject,
     PAGED_CODE();
 
     /* Loop path separators at the end */
-    while ((RemainingName->Length) &&
+    while (RemainingName->Length &&
            (RemainingName->Buffer[(RemainingName->Length / sizeof(WCHAR)) - 1] 
==
             OBJ_NAME_PATH_SEPARATOR))
     {
@@ -1888,7 +1888,7 @@ CmpParseKey(IN PVOID ParseObject,
     Current = *RemainingName;
 
     /* Check if this is a create */
-    if (!(ParseContext) || !(ParseContext->CreateOperation))
+    if (!ParseContext || !ParseContext->CreateOperation)
     {
         /* It isn't, so no context */
         ParseContext = NULL;
@@ -2043,7 +2043,7 @@ CmpParseKey(IN PVOID ParseObject,
     {
         /* Get the next component */
         Result = CmpGetNextName(&Current, &NextName, &Last);
-        if ((Result) && (NextName.Length))
+        if (Result && NextName.Length)
         {
             /* See if this is a sym link */
             if (!(Kcb->Flags & KEY_SYM_LINK))
@@ -2150,7 +2150,7 @@ KeyCachedOpenNow:
                 else
                 {
                     /* Check if this was the last key for a create */
-                    if ((Last) && (ParseContext))
+                    if (Last && ParseContext)
                     {
                         /* Check if we're doing a link node */
                         if (ParseContext->CreateLink)
@@ -2246,7 +2246,7 @@ KeyCachedOpenNow:
                 break;
             }
         }
-        else if ((Result) && (Last))
+        else if (Result && Last)
         {
             /* Opening the root. Is this an exit node? */
             if (Node->Flags & KEY_HIVE_EXIT)
diff --git a/ntoskrnl/config/cmse.c b/ntoskrnl/config/cmse.c
index 6c8c55472b8..add246cebe2 100644
--- a/ntoskrnl/config/cmse.c
+++ b/ntoskrnl/config/cmse.c
@@ -40,7 +40,7 @@ CmpHiveRootSecurityDescriptor(VOID)
     Sid[3] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CMSD);
 
     /* Make sure all SIDs were allocated */
-    if (!(Sid[0]) || !(Sid[1]) || !(Sid[2]) || !(Sid[3]))
+    if (!Sid[0] || !Sid[1] || !Sid[2] || !Sid[3])
     {
         /* Bugcheck */
         KeBugCheckEx(REGISTRY_ERROR, 11, 1, 0, 0);
diff --git a/ntoskrnl/config/cmsysini.c b/ntoskrnl/config/cmsysini.c
index d28a5b5d20d..48bb2c1a3de 100644
--- a/ntoskrnl/config/cmsysini.c
+++ b/ntoskrnl/config/cmsysini.c
@@ -228,7 +228,7 @@ CmpQueryKeyName(IN PVOID ObjectBody,
 
     /* Check if the provided buffer is too small to fit even anything */
     if ((Length <= sizeof(OBJECT_NAME_INFORMATION)) ||
-        ((Length < (*ReturnLength)) && (BytesToCopy < sizeof(WCHAR))))
+        ((Length < *ReturnLength) && (BytesToCopy < sizeof(WCHAR))))
     {
         /* Free the buffer allocated by CmpConstructName */
         ExFreePoolWithTag(KeyName, TAG_CM);
@@ -238,7 +238,7 @@ CmpQueryKeyName(IN PVOID ObjectBody,
     }
 
     /* Check if the provided buffer can be partially written */
-    if (Length < (*ReturnLength))
+    if (Length < *ReturnLength)
     {
         /* Yes, indicate so in the return status */
         Status = STATUS_INFO_LENGTH_MISMATCH;
@@ -687,7 +687,7 @@ CmpCreateControlSet(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
         ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer;
 
         /* Check if we failed or got a non DWORD-value */
-        if (!(NT_SUCCESS(Status)) || (ValueInfo->Type != REG_DWORD))
+        if (!NT_SUCCESS(Status) || (ValueInfo->Type != REG_DWORD))
         {
             Status = STATUS_SUCCESS;
             goto Cleanup;
@@ -728,7 +728,7 @@ CmpCreateControlSet(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     Status = NtOpenKey(&ProfileHandle,
                        KEY_READ | KEY_WRITE,
                        &ObjectAttributes);
-    if (!NT_SUCCESS (Status))
+    if (!NT_SUCCESS(Status))
     {
         /* Cleanup and exit */
         Status = STATUS_SUCCESS;
@@ -1319,8 +1319,8 @@ CmpLoadHiveThread(IN PVOID StartContext)
                                      &CmHive,
                                      &CmpMachineHiveList[i].Allocate,
                                      CM_CHECK_REGISTRY_PURGE_VOLATILES);
-        if (!(NT_SUCCESS(Status)) ||
-            (!(CmpShareSystemHives) && !(CmHive->FileHandles[HFILE_TYPE_LOG])))
+        if (!NT_SUCCESS(Status) ||
+            (!CmpShareSystemHives && !CmHive->FileHandles[HFILE_TYPE_LOG]))
         {
             /*
              * We failed, or could not get a log file (unless
@@ -1356,7 +1356,7 @@ CmpLoadHiveThread(IN PVOID StartContext)
                                       TRUE,
                                       FALSE,
                                       &ClusterSize);
-            if (!(NT_SUCCESS(Status)) || !(AlternateHandle))
+            if (!NT_SUCCESS(Status) || !AlternateHandle)
             {
                 /* Couldn't open the hive or its alternate file, raise a hard 
error */
                 ErrorParameters = &FileName;
@@ -2111,14 +2111,14 @@ CmpReleaseTwoKcbLockByKey(IN ULONG ConvKey1,
     Index1 = GET_HASH_INDEX(ConvKey1);
     Index2 = GET_HASH_INDEX(ConvKey2);
     ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey2)->Owner == 
KeGetCurrentThread()) ||
-           (CmpTestRegistryLockExclusive()));
+           CmpTestRegistryLockExclusive());
 
     /* See which one is highest */
     if (Index1 < Index2)
     {
         /* Grab them in the proper order */
         ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey1)->Owner == 
KeGetCurrentThread()) ||
-               (CmpTestRegistryLockExclusive()));
+               CmpTestRegistryLockExclusive());
         CmpReleaseKcbLockByKey(ConvKey2);
         CmpReleaseKcbLockByKey(ConvKey1);
     }
@@ -2128,7 +2128,7 @@ CmpReleaseTwoKcbLockByKey(IN ULONG ConvKey1,
         if (Index1 != Index2)
         {
             ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey1)->Owner == 
KeGetCurrentThread()) ||
-                   (CmpTestRegistryLockExclusive()));
+                   CmpTestRegistryLockExclusive());
             CmpReleaseKcbLockByKey(ConvKey1);
         }
         CmpReleaseKcbLockByKey(ConvKey2);
diff --git a/ntoskrnl/config/cmvalche.c b/ntoskrnl/config/cmvalche.c
index fe82bea8163..c63e03b4c51 100644
--- a/ntoskrnl/config/cmvalche.c
+++ b/ntoskrnl/config/cmvalche.c
@@ -69,8 +69,8 @@ CmpGetValueListFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
     else
     {
         /* Make sure the KCB is locked exclusive */
-        if (!(CmpIsKcbLockedExclusive(Kcb)) &&
-            !(CmpTryToConvertKcbSharedToExclusive(Kcb)))
+        if (!CmpIsKcbLockedExclusive(Kcb) &&
+            !CmpTryToConvertKcbSharedToExclusive(Kcb))
         {
             /* We need the exclusive lock */
             return SearchNeedExclusiveLock;
@@ -79,7 +79,7 @@ CmpGetValueListFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
         /* Select the value list as our cell, and get the actual list array */
         CellToRelease = ChildList->ValueList;
         *CellData = (PCELL_DATA)HvGetCell(Hive, CellToRelease);
-        if (!(*CellData)) return SearchFail;
+        if (!*CellData) return SearchFail;
 
         /* FIXME: Here we would cache the value */
 
@@ -229,7 +229,7 @@ CmpFindValueByNameFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
         if (SearchResult != SearchSuccess)
         {
             /* We either failed or need the exclusive lock */
-            ASSERT((SearchResult == SearchFail) || 
!(CmpIsKcbLockedExclusive(Kcb)));
+            ASSERT((SearchResult == SearchFail) || 
!CmpIsKcbLockedExclusive(Kcb));
             ASSERT(Cell == HCELL_NIL);
             return SearchResult;
         }
@@ -260,7 +260,7 @@ CmpFindValueByNameFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
             if (SearchResult != SearchSuccess)
             {
                 /* We either failed or need the exclusive lock */
-                ASSERT((SearchResult == SearchFail) || 
!(CmpIsKcbLockedExclusive(Kcb)));
+                ASSERT((SearchResult == SearchFail) || 
!CmpIsKcbLockedExclusive(Kcb));
                 ASSERT(Cell == HCELL_NIL);
                 return SearchResult;
             }
@@ -552,7 +552,7 @@ CmpQueryKeyValueData(IN PCM_KEY_CONTROL_BLOCK Kcb,
                 }
 
                 /* Sanity check */
-                ASSERT((IsSmall ? (Size <= CM_KEY_VALUE_SMALL) : TRUE));
+                ASSERT(IsSmall ? (Size <= CM_KEY_VALUE_SMALL) : TRUE);
 
                 /* Make sure we have a valid buffer */
                 if (Buffer)
@@ -658,7 +658,7 @@ CmpQueryKeyValueData(IN PCM_KEY_CONTROL_BLOCK Kcb,
                 }
 
                 /* Sanity check */
-                ASSERT((IsSmall ? (Size <= CM_KEY_VALUE_SMALL) : TRUE));
+                ASSERT(IsSmall ? (Size <= CM_KEY_VALUE_SMALL) : TRUE);
 
                 /* Make sure we have a valid buffer */
                 if (Buffer)
@@ -719,8 +719,8 @@ CmpCompareNewValueDataAgainstKCBCache(IN 
PCM_KEY_CONTROL_BLOCK Kcb,
     if (Kcb->Flags & KEY_SYM_LINK)
     {
         /* We need the exclusive lock */
-        if (!(CmpIsKcbLockedExclusive(Kcb)) &&
-            !(CmpTryToConvertKcbSharedToExclusive(Kcb)))
+        if (!CmpIsKcbLockedExclusive(Kcb) &&
+            !CmpTryToConvertKcbSharedToExclusive(Kcb))
         {
             /* We need the exclusive lock */
             return SearchNeedExclusiveLock;
@@ -734,7 +734,7 @@ CmpCompareNewValueDataAgainstKCBCache(IN 
PCM_KEY_CONTROL_BLOCK Kcb,
         CmpCleanUpKcbValueCache(Kcb);
 
         /* Sanity checks */
-        ASSERT(!(CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList)));
+        ASSERT(!CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList));
         ASSERT(!(Kcb->ExtFlags & CM_KCB_SYM_LINK_FOUND));
 
         /* Set the value cache */
diff --git a/ntoskrnl/config/ntapi.c b/ntoskrnl/config/ntapi.c
index 5e8f356a229..5bf9ec5af0b 100644
--- a/ntoskrnl/config/ntapi.c
+++ b/ntoskrnl/config/ntapi.c
@@ -805,7 +805,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
         goto Quit;
 
     /* Make sure the name is aligned properly */
-    if ((ValueNameCopy.Length & (sizeof(WCHAR) - 1)))
+    if (ValueNameCopy.Length & (sizeof(WCHAR) - 1))
     {
         /* It isn't, so we'll fail */
         Status = STATUS_INVALID_PARAMETER;
@@ -813,7 +813,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
     }
 
     /* Ignore any null characters at the end */
-    while ((ValueNameCopy.Length) &&
+    while (ValueNameCopy.Length &&
            !(ValueNameCopy.Buffer[ValueNameCopy.Length / sizeof(WCHAR) - 1]))
     {
         /* Skip it */
@@ -947,9 +947,9 @@ NtSetValueKey(IN HANDLE KeyHandle,
         KeyHandle, &ValueNameCopy, TitleIndex, Type, DataSize);
 
     /* Make sure the name is aligned, not too long, and the data under 4GB */
-    if ( (ValueNameCopy.Length > 32767) ||
-         ((ValueNameCopy.Length & (sizeof(WCHAR) - 1))) ||
-         (DataSize > 0x80000000))
+    if ((ValueNameCopy.Length > 32767) ||
+        (ValueNameCopy.Length & (sizeof(WCHAR) - 1)) ||
+        (DataSize > 0x80000000))
     {
         /* Fail */
         Status = STATUS_INVALID_PARAMETER;
@@ -957,7 +957,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
     }
 
     /* Ignore any null characters at the end */
-    while ((ValueNameCopy.Length) &&
+    while (ValueNameCopy.Length &&
            !(ValueNameCopy.Buffer[ValueNameCopy.Length / sizeof(WCHAR) - 1]))
     {
         /* Skip it */
@@ -1039,7 +1039,7 @@ NtDeleteValueKey(IN HANDLE KeyHandle,
         goto Quit;
 
     /* Make sure the name is aligned properly */
-    if ((ValueNameCopy.Length & (sizeof(WCHAR) - 1)))
+    if (ValueNameCopy.Length & (sizeof(WCHAR) - 1))
     {
         /* It isn't, so we'll fail */
         Status = STATUS_INVALID_PARAMETER;
diff --git a/sdk/lib/cmlib/hivewrt.c b/sdk/lib/cmlib/hivewrt.c
index d95e8559196..eff699ac876 100644
--- a/sdk/lib/cmlib/hivewrt.c
+++ b/sdk/lib/cmlib/hivewrt.c
@@ -101,7 +101,7 @@ HvpWriteLog(
      * The hive log we are going to write data into
      * has to be writable and with a sane storage.
      */
-    ASSERT(RegistryHive->ReadOnly == FALSE);
+    ASSERT(!RegistryHive->ReadOnly);
     ASSERT(RegistryHive->BaseBlock->Length ==
            RegistryHive->Storage[Stable].Length * HBLOCK_SIZE);
 
@@ -109,12 +109,11 @@ HvpWriteLog(
     HvpValidateBaseHeader(RegistryHive);
 
     /*
-     * The sequences can diverge in an occurrence of forced
-     * shutdown of the system such as during a power failure,
-     * the hardware crapping itself or during a system crash
-     * when one of the sequences have been modified during
-     * writing into the log or hive. In such cases the hive
-     * needs a repair.
+     * The sequences can diverge during a forced system shutdown
+     * occurrence, such as during a power failure, a hardware
+     * failure or during a system crash, and when one of the
+     * sequences have been modified during writing into the log
+     * or hive. In such cases the hive needs a repair.
      */
     if (RegistryHive->BaseBlock->Sequence1 !=
         RegistryHive->BaseBlock->Sequence2)
@@ -324,7 +323,7 @@ HvpWriteHive(
     ULONG LastIndex;
     PVOID Block;
 
-    ASSERT(RegistryHive->ReadOnly == FALSE);
+    ASSERT(!RegistryHive->ReadOnly);
     ASSERT(RegistryHive->BaseBlock->Length ==
            RegistryHive->Storage[Stable].Length * HBLOCK_SIZE);
     ASSERT(RegistryHive->BaseBlock->RootCell != HCELL_NIL);
@@ -333,12 +332,11 @@ HvpWriteHive(
     HvpValidateBaseHeader(RegistryHive);
 
     /*
-     * The sequences can diverge in an occurrence of forced
-     * shutdown of the system such as during a power failure,
-     * the hardware crapping itself or during a system crash
-     * when one of the sequences have been modified during
-     * writing into the log or hive. In such cases the hive
-     * needs a repair.
+     * The sequences can diverge during a forced system shutdown
+     * occurrence, such as during a power failure, a hardware
+     * failure or during a system crash, and when one of the
+     * sequences have been modified during writing into the log
+     * or hive. In such cases the hive needs a repair.
      */
     if (RegistryHive->BaseBlock->Sequence1 !=
         RegistryHive->BaseBlock->Sequence2)
@@ -372,11 +370,11 @@ HvpWriteHive(
     while (BlockIndex < RegistryHive->Storage[Stable].Length)
     {
         /*
-         * If we have to syncrhonize the registry hive we
+         * If we have to synchronize the registry hive we
          * want to look for dirty blocks to reflect the new
          * updates done to the hive. Otherwise just write
          * all the blocks as if we were doing a regular
-         * writing of the hive.
+         * hive write.
          */
         if (OnlyDirty)
         {
@@ -420,9 +418,9 @@ HvpWriteHive(
 
     /*
      * Increment the secondary sequence number and
-     * update the checksum. A successful transaction
-     * writing of hive is both of sequences are the
-     * same indicating the writing operation didn't
+     * update the checksum. A successful hive write
+     * transaction is when both of sequences are the
+     * same, indicating the write operation didn't
      * fail.
      */
     RegistryHive->BaseBlock->Sequence2++;
@@ -476,7 +474,7 @@ HvSyncHive(
     BOOLEAN HardErrors;
 #endif
 
-    ASSERT(RegistryHive->ReadOnly == FALSE);
+    ASSERT(!RegistryHive->ReadOnly);
     ASSERT(RegistryHive->Signature == HV_HHIVE_SIGNATURE);
 
     /*
@@ -522,8 +520,8 @@ HvSyncHive(
     KeQuerySystemTime(&RegistryHive->BaseBlock->TimeStamp);
 #endif
 
-    /* Update the log file of hive if present */
-    if (RegistryHive->Log == TRUE)
+    /* Update the hive log file if present */
+    if (RegistryHive->Log)
     {
         if (!HvpWriteLog(RegistryHive))
         {
@@ -546,7 +544,7 @@ HvSyncHive(
     }
 
     /* Update the alternate hive file if present */
-    if (RegistryHive->Alternate == TRUE)
+    if (RegistryHive->Alternate)
     {
         if (!HvpWriteHive(RegistryHive, TRUE, HFILE_TYPE_ALTERNATE))
         {
@@ -615,7 +613,7 @@ CMAPI
 HvWriteHive(
     _In_ PHHIVE RegistryHive)
 {
-    ASSERT(RegistryHive->ReadOnly == FALSE);
+    ASSERT(!RegistryHive->ReadOnly);
     ASSERT(RegistryHive->Signature == HV_HHIVE_SIGNATURE);
 
 #if !defined(_BLDR_)
@@ -653,9 +651,9 @@ CMAPI
 HvWriteAlternateHive(
     _In_ PHHIVE RegistryHive)
 {
-    ASSERT(RegistryHive->ReadOnly == FALSE);
+    ASSERT(!RegistryHive->ReadOnly);
     ASSERT(RegistryHive->Signature == HV_HHIVE_SIGNATURE);
-    ASSERT(RegistryHive->Alternate == TRUE);
+    ASSERT(RegistryHive->Alternate);
 
 #if !defined(_BLDR_)
     /* Update hive header modification time */
@@ -691,7 +689,7 @@ CMAPI
 HvSyncHiveFromRecover(
     _In_ PHHIVE RegistryHive)
 {
-    ASSERT(RegistryHive->ReadOnly == FALSE);
+    ASSERT(!RegistryHive->ReadOnly);
     ASSERT(RegistryHive->Signature == HV_HHIVE_SIGNATURE);
 
     /* Call the private API call to do the deed for us */

Reply via email to