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

commit ee5338ff135f5d958c447efb0ae7f8c1b993eb50
Author:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
AuthorDate: Sun Sep 29 16:24:25 2024 +0200
Commit:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
CommitDate: Tue Oct 8 17:48:03 2024 +0200

    [CMLIB] Fix GCC13 print formatting '%lu' warning (#7408)
    
    CORE-19724
    
    sdk/lib/cmlib/cmcheck.c: Print the HCELL_INDEX indices in hexadecimal.
    
    ------------------
    
    sdk/lib/cmlib/cmcheck.c:321:60: warning: format '%lu' expects argument of 
type 'long unsigned int', but argument 2 has type 'ULONG' {aka 'unsigned int'} 
[-Wformat=]
    
    and at lines 341, 357, 374, 554, 579, 733, 760, 801, 984, 1003, 1458,
    1476, 1521, 1551, 1670
    
    sdk/lib/cmlib/cmcheck.c:1251:65: warning: format '%lu' expects argument of 
type 'long unsigned int', but argument 2 has type 'HCELL_INDEX' {aka 'unsigned 
int'} [-Wformat=]
    
    and at lines 1282, 1303, 1551
    
    sdk/lib/cmlib/cmcheck.c:1326:79: warning: format '%lu' expects argument of 
type 'long unsigned int', but argument 2 has type 'LONG' {aka 'int'} [-Wformat=]
    
    sdk/lib/cmlib/cmcheck.c:1684:76: warning: format '%lu' expects argument of 
type 'long unsigned int', but argument 3 has type 'CM_CHECK_REGISTRY_STATUS' 
{aka 'unsigned int'} [-Wformat=]
    
    and at line 1711
    
    ------------------
    
    sdk/lib/cmlib/cmheal.c:223:108: warning: format '%lu' expects argument of 
type 'long unsigned int', but argument 3 has type 'ULONG' {aka 'unsigned int'} 
[-Wformat=]
    
    and at lines 240, 319, 335
    
    sdk/lib/cmlib/cmheal.c:480:79: warning: format '%lu' expects argument of 
type 'long unsigned int', but argument 2 has type 'int' [-Wformat=]
    
    ------------------
    
    sdk/lib/cmlib/hiveinit.c:976:62: warning: format '%lu' expects argument of 
type 'long unsigned int', but argument 2 has type 'ULONG' {aka 'unsigned int'} 
[-Wformat=]
    
    and at lines 988, 1492
---
 sdk/lib/cmlib/cmcheck.c  | 49 +++++++++++++++++++++++++-----------------------
 sdk/lib/cmlib/cmheal.c   | 11 ++++++-----
 sdk/lib/cmlib/hivecell.c | 12 ++++++------
 sdk/lib/cmlib/hiveinit.c |  6 +++---
 4 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/sdk/lib/cmlib/cmcheck.c b/sdk/lib/cmlib/cmcheck.c
index 0c1d82b0555..88de8b75215 100644
--- a/sdk/lib/cmlib/cmcheck.c
+++ b/sdk/lib/cmlib/cmcheck.c
@@ -318,7 +318,7 @@ CmpValidateValueListByCount(
                                          ValueListData,
                                          FixHive))
             {
-                DPRINT1("The value cell is NIL (at index %lu, list count 
%lu)\n",
+                DPRINT1("The value cell is NIL (at index %u, list count %u)\n",
                         ListCountIndex, ListCount);
                 return CM_CHECK_REGISTRY_VALUE_CELL_NIL;
             }
@@ -338,7 +338,7 @@ CmpValidateValueListByCount(
                                          ValueListData,
                                          FixHive))
             {
-                DPRINT1("The value cell is not allocated (at index %lu, list 
count %lu)\n",
+                DPRINT1("The value cell is not allocated (at index %u, list 
count %u)\n",
                         ListCountIndex, ListCount);
                 return CM_CHECK_REGISTRY_VALUE_CELL_UNALLOCATED;
             }
@@ -354,7 +354,7 @@ CmpValidateValueListByCount(
         ValueData = (PCELL_DATA)HvGetCell(Hive, ValueCell);
         if (!ValueData)
         {
-            DPRINT1("Cell data of the value cell not found (at index %lu, 
value count %lu)\n",
+            DPRINT1("Cell data of the value cell not found (at index %u, value 
count %u)\n",
                     ListCountIndex, ListCount);
             return CM_CHECK_REGISTRY_VALUE_CELL_DATA_NOT_FOUND;
         }
@@ -371,7 +371,7 @@ CmpValidateValueListByCount(
                                          ValueListData,
                                          FixHive))
             {
-                DPRINT1("The total size is bigger than the actual cell size 
(total size %lu, cell size %lu, at index %lu)\n",
+                DPRINT1("The total size is bigger than the actual cell size 
(total size %u, cell size %u, at index %u)\n",
                         TotalValueNameLength, ValueDataSize, ListCountIndex);
                 return CM_CHECK_REGISTRY_VALUE_CELL_SIZE_NOT_SANE;
             }
@@ -551,7 +551,7 @@ CmpValidateValueList(
         TotalValueLength = ValueListCount * sizeof(HCELL_INDEX);
         if (TotalValueLength > ValueSize)
         {
-            DPRINT1("The value list is bigger than the cell (value list size 
%lu, cell size %lu)\n",
+            DPRINT1("The value list is bigger than the cell (value list size 
%u, cell size %u)\n",
                     TotalValueLength, ValueSize);
             return CM_CHECK_REGISTRY_VALUE_LIST_SIZE_NOT_SANE;
         }
@@ -576,7 +576,7 @@ CmpValidateValueList(
         /* Log how much values have been removed */
         if (ValuesRemoved > 0)
         {
-            DPRINT1("Values removed in the list -- %lu\n", ValuesRemoved);
+            DPRINT1("%u values removed in the list\n", ValuesRemoved);
         }
     }
 
@@ -730,7 +730,7 @@ CmpValidateSubKeyList(
                                            CellData,
                                            FixHive))
                 {
-                    DPRINT1("The subkeys list has invalid count (subkeys count 
%lu, root key index count %lu)\n",
+                    DPRINT1("The subkeys list has invalid count (subkeys count 
%u, root key index count %u)\n",
                             SubKeyCounts, RootKeyIndex->Count);
                     return CM_CHECK_REGISTRY_BAD_SUBKEY_COUNT;
                 }
@@ -757,7 +757,7 @@ CmpValidateSubKeyList(
                 KeyIndexCell = RootKeyIndex->List[RootIndex];
                 if (!HvIsCellAllocated(Hive, KeyIndexCell))
                 {
-                    DPRINT1("The key index cell is not allocated at index 
%lu\n", RootIndex);
+                    DPRINT1("The key index cell is not allocated at index 
%u\n", RootIndex);
                     *DoRepair = TRUE;
                     return CM_CHECK_REGISTRY_KEY_INDEX_CELL_UNALLOCATED;
                 }
@@ -798,7 +798,7 @@ CmpValidateSubKeyList(
                                            CellData,
                                            FixHive))
                 {
-                    DPRINT1("The subkeys list has invalid count (subkeys count 
%lu, total leaf count %lu)\n",
+                    DPRINT1("The subkeys list has invalid count (subkeys count 
%u, total leaf count %u)\n",
                             SubKeyCounts, TotalLeafCount);
                     return CM_CHECK_REGISTRY_BAD_SUBKEY_COUNT;
                 }
@@ -981,7 +981,7 @@ CmpValidateKey(
     CellSize = HvGetCellSize(Hive, CellData);
     if (CellSize > CMP_KEY_SIZE_THRESHOLD)
     {
-        DPRINT1("The cell size is above the threshold size (size %lu)\n", 
CellSize);
+        DPRINT1("The cell size is above the threshold size (size %u)\n", 
CellSize);
         return CM_CHECK_REGISTRY_CELL_SIZE_NOT_SANE;
     }
 
@@ -1000,7 +1000,8 @@ CmpValidateKey(
     TotalKeyNameLength = NameLength + FIELD_OFFSET(CM_KEY_NODE, Name);
     if (TotalKeyNameLength > CellSize)
     {
-        DPRINT1("The key is too big than the cell (key size %lu, cell size 
%lu)\n", TotalKeyNameLength, CellSize);
+        DPRINT1("The key is too big than the cell (key size %u, cell size 
%u)\n",
+                TotalKeyNameLength, CellSize);
         return CM_CHECK_REGISTRY_KEY_TOO_BIG_THAN_CELL;
     }
 
@@ -1248,7 +1249,7 @@ RestartValidation:
                  */
                 if (!CmpRepairParentKey(Hive, CurrentCell, ParentCell, 
FixHive))
                 {
-                    DPRINT1("The key is corrupt (current cell %lu, parent cell 
%lu)\n",
+                    DPRINT1("The key is corrupt (current cell 0x%x, parent 
cell 0x%x)\n",
                             CurrentCell, ParentCell);
                     CmpFree(WorkState, WorkStateLength);
                     return CmStatusCode;
@@ -1279,8 +1280,8 @@ RestartValidation:
                          */
                         if (!CmpRepairParentKey(Hive, CurrentCell, ParentCell, 
FixHive))
                         {
-                            DPRINT1("The lexicographical order is invalid 
(sibling %lu, current cell %lu)\n",
-                            CurrentCell, WorkState[StackDepth - 
CMP_PRIOR_STACK].Sibling);
+                            DPRINT1("The lexicographical order is invalid 
(sibling 0x%x, current cell 0x%x)\n",
+                                    CurrentCell, WorkState[StackDepth - 
CMP_PRIOR_STACK].Sibling);
                             CmpFree(WorkState, WorkStateLength);
                             return CM_CHECK_REGISTRY_BAD_LEXICOGRAPHICAL_ORDER;
                         }
@@ -1300,7 +1301,7 @@ RestartValidation:
         KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, CurrentCell);
         if (!KeyNode)
         {
-            DPRINT1("Couldn't get the node of key (current cell %lu)\n", 
CurrentCell);
+            DPRINT1("Couldn't get the node of key (current cell 0x%x)\n", 
CurrentCell);
             CmpFree(WorkState, WorkStateLength);
             return CM_CHECK_REGISTRY_NODE_NOT_FOUND;
         }
@@ -1323,7 +1324,7 @@ RestartValidation:
             ChildSubKeyCell = CmpFindSubKeyByNumber(Hive, KeyNode, 
WorkState[StackDepth].ChildCellIndex);
             if (ChildSubKeyCell == HCELL_NIL)
             {
-                DPRINT1("Couldn't get the child subkey cell (at stack index 
%lu)\n", StackDepth);
+                DPRINT1("Couldn't get the child subkey cell (at stack index 
%d)\n", StackDepth);
                 CmpFree(WorkState, WorkStateLength);
                 return CM_CHECK_REGISTRY_SUBKEY_NOT_FOUND;
             }
@@ -1455,7 +1456,7 @@ HvValidateBin(
                  * free space (aka Size == 0) which is a
                  * no go for a bin.
                  */
-                DPRINT1("The free cell exceeds the bin size or cell size equal 
to 0 (cell 0x%p, cell size %d, bin size %lu)\n",
+                DPRINT1("The free cell exceeds the bin size or cell size equal 
to 0 (cell 0x%p, cell size %d, bin size %u)\n",
                         Cell, Cell->Size, Bin->Size);
                 return CM_CHECK_REGISTRY_BAD_FREE_CELL;
             }
@@ -1473,7 +1474,7 @@ HvValidateBin(
                  * that exceeds the boundary of the
                  * bin size.
                  */
-                DPRINT1("The allocated cell exceeds the bin size (cell 0x%p, 
cell size %d, bin size %lu)\n",
+                DPRINT1("The allocated cell exceeds the bin size (cell 0x%p, 
cell size %d, bin size %u)\n",
                         Cell, abs(Cell->Size), Bin->Size);
                 return CM_CHECK_REGISTRY_BAD_ALLOC_CELL;
             }
@@ -1518,7 +1519,7 @@ HvValidateHive(
     /* Is the hive signature valid? */
     if (Hive->Signature != HV_HHIVE_SIGNATURE)
     {
-        DPRINT1("Hive's signature corrupted (signature %lu)\n", 
Hive->Signature);
+        DPRINT1("Hive's signature corrupted (signature %u)\n", 
Hive->Signature);
         return CM_CHECK_REGISTRY_HIVE_CORRUPT_SIGNATURE;
     }
 
@@ -1548,7 +1549,7 @@ HvValidateHive(
             if (Bin->Size > (StorageLength * HBLOCK_SIZE) ||
                 (Bin->FileOffset / HBLOCK_SIZE) != BlockIndex)
             {
-                DPRINT1("Bin size or offset is corrupt (bin size %lu, file 
offset %lu, storage length %lu)\n",
+                DPRINT1("Bin size or offset is corrupt (bin size %u, file 
offset %u, storage length %u)\n",
                         Bin->Size, Bin->FileOffset, StorageLength);
                 return CM_CHECK_REGISTRY_BIN_SIZE_OR_OFFSET_CORRUPT;
             }
@@ -1667,7 +1668,7 @@ CmCheckRegistry(
                   CM_CHECK_REGISTRY_VALIDATE_HIVE              |
                   CM_CHECK_REGISTRY_FIX_HIVE))
     {
-        DPRINT1("Invalid flag for registry check given (flag %lu)\n", Flags);
+        DPRINT1("Invalid flag for registry check given (flag %u)\n", Flags);
         return CM_CHECK_REGISTRY_INVALID_PARAMETER;
     }
 
@@ -1681,7 +1682,8 @@ CmCheckRegistry(
         CmStatusCode = HvValidateHive(Hive);
         if (!CM_CHECK_REGISTRY_SUCCESS(CmStatusCode))
         {
-            DPRINT1("The hive is not valid (hive 0x%p, check status code 
%lu)\n", Hive, CmStatusCode);
+            DPRINT1("The hive is not valid (hive 0x%p, check status code 
%u)\n",
+                    Hive, CmStatusCode);
             return CmStatusCode;
         }
     }
@@ -1708,7 +1710,8 @@ CmCheckRegistry(
     CmStatusCode = CmpValidateRegistryInternal(Hive, Flags, FALSE, 
ShouldFixHive);
     if (!CM_CHECK_REGISTRY_SUCCESS(CmStatusCode))
     {
-        DPRINT1("The hive is not valid (hive 0x%p, check status code %lu)\n", 
Hive, CmStatusCode);
+        DPRINT1("The hive is not valid (hive 0x%p, check status code %u)\n",
+                Hive, CmStatusCode);
         return CmStatusCode;
     }
 
diff --git a/sdk/lib/cmlib/cmheal.c b/sdk/lib/cmlib/cmheal.c
index 9489d621bed..08b526ff04a 100644
--- a/sdk/lib/cmlib/cmheal.c
+++ b/sdk/lib/cmlib/cmheal.c
@@ -220,7 +220,7 @@ CmpRemoveSubkeyInRoot(
                     HvReleaseCell(Hive, LeafCell);
                     HvMarkCellDirty(Hive, LeafCell, FALSE);
                     CmpRemoveFastIndexKeyCell(FastIndex, LeafCountIndex, TRUE);
-                    DPRINT1("The offending key cell has BEEN FOUND in fast 
index (fast index 0x%p, index %lu)\n",
+                    DPRINT1("The offending key cell has BEEN FOUND in fast 
index (fast index 0x%p, index %u)\n",
                             FastIndex, LeafCountIndex);
                     return TRUE;
                 }
@@ -237,7 +237,7 @@ CmpRemoveSubkeyInRoot(
                     HvReleaseCell(Hive, LeafCell);
                     HvMarkCellDirty(Hive, LeafCell, FALSE);
                     CmpRemoveIndexKeyCell(Leaf, LeafCountIndex);
-                    DPRINT1("The offending key cell has BEEN FOUND in leaf 
(leaf 0x%p, index %lu)\n",
+                    DPRINT1("The offending key cell has BEEN FOUND in leaf 
(leaf 0x%p, index %u)\n",
                             Leaf, LeafCountIndex);
                     return TRUE;
                 }
@@ -316,7 +316,7 @@ CmpRemoveSubKeyInLeaf(
                  * rather than that of the fast index.
                  */
                 Leaf->Count--;
-                DPRINT1("The offending key cell has BEEN FOUND in fast index 
(fast index 0x%p, leaf index %lu)\n",
+                DPRINT1("The offending key cell has BEEN FOUND in fast index 
(fast index 0x%p, leaf index %u)\n",
                         FastIndex, LeafIndex);
                 return TRUE;
             }
@@ -332,7 +332,7 @@ CmpRemoveSubKeyInLeaf(
             {
                 HvMarkCellDirty(Hive, KeyNode->SubKeyLists[Stable], FALSE);
                 CmpRemoveIndexKeyCell(Leaf, LeafIndex);
-                DPRINT1("The offending key cell has BEEN FOUND in leaf (leaf 
0x%p, index %lu)\n",
+                DPRINT1("The offending key cell has BEEN FOUND in leaf (leaf 
0x%p, index %u)\n",
                         Leaf, LeafIndex);
                 return TRUE;
             }
@@ -477,7 +477,8 @@ CmpRepairParentKey(
          * if for whatever reason we reach here then something
          * is seriously wrong.
          */
-        DPRINT1("The key index signature is invalid (KeyIndex->Signature == 
%lu)", KeyIndex->Signature);
+        DPRINT1("The key index signature is invalid (KeyIndex->Signature == 
%u)",
+                KeyIndex->Signature);
         ASSERT(FALSE);
     }
 
diff --git a/sdk/lib/cmlib/hivecell.c b/sdk/lib/cmlib/hivecell.c
index 2354631ad8c..8630d87c67f 100644
--- a/sdk/lib/cmlib/hivecell.c
+++ b/sdk/lib/cmlib/hivecell.c
@@ -26,7 +26,7 @@ HvpGetCellHeader(
 {
     PVOID Block;
 
-    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx\n",
+    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive 0x%p, CellIndex 0x%x\n",
              __FUNCTION__, RegistryHive, CellIndex);
 
     ASSERT(CellIndex != HCELL_NIL);
@@ -116,7 +116,7 @@ HvMarkCellDirty(
 
     ASSERT(RegistryHive->ReadOnly == FALSE);
 
-    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx, HoldingLock 
%u\n",
+    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive 0x%p, CellIndex 0x%x, HoldingLock 
%u\n",
              __FUNCTION__, RegistryHive, CellIndex, HoldingLock);
 
     if (HvGetCellType(CellIndex) != Stable)
@@ -367,7 +367,7 @@ HvAllocateCell(
 
     ASSERT(RegistryHive->ReadOnly == FALSE);
 
-    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, Size %x, %s, Vicinity %08lx\n",
+    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive 0x%p, Size 0x%x, %s, Vicinity 
0x%x\n",
              __FUNCTION__, RegistryHive, Size, (Storage == 0) ? "Stable" : 
"Volatile", Vicinity);
 
     /* Round to 16 bytes multiple. */
@@ -411,7 +411,7 @@ HvAllocateCell(
     FreeCell->Size = -FreeCell->Size;
     RtlZeroMemory(FreeCell + 1, Size - sizeof(HCELL));
 
-    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - CellIndex %08lx\n",
+    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - CellIndex 0x%x\n",
              __FUNCTION__, FreeCellOffset);
 
     return FreeCellOffset;
@@ -431,7 +431,7 @@ HvReallocateCell(
 
     ASSERT(CellIndex != HCELL_NIL);
 
-    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx, Size %x\n",
+    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive 0x%p, CellIndex 0x%x, Size 0x%x\n",
              __FUNCTION__, RegistryHive, CellIndex, Size);
 
     Storage = HvGetCellType(CellIndex);
@@ -477,7 +477,7 @@ HvFreeCell(
 
     ASSERT(RegistryHive->ReadOnly == FALSE);
 
-    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx\n",
+    CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive 0x%p, CellIndex 0x%x\n",
              __FUNCTION__, RegistryHive, CellIndex);
 
     Free = HvpGetCellHeader(RegistryHive, CellIndex);
diff --git a/sdk/lib/cmlib/hiveinit.c b/sdk/lib/cmlib/hiveinit.c
index d79c9dadad3..133232de613 100644
--- a/sdk/lib/cmlib/hiveinit.c
+++ b/sdk/lib/cmlib/hiveinit.c
@@ -973,7 +973,7 @@ HvpRecoverDataFromLog(
                                  HBLOCK_SIZE);
         if (!Success)
         {
-            DPRINT1("Failed to read the dirty block (index %lu)\n", 
BlockIndex);
+            DPRINT1("Failed to read the dirty block (index %u)\n", BlockIndex);
             return Fail;
         }
 
@@ -985,7 +985,7 @@ HvpRecoverDataFromLog(
                                   HBLOCK_SIZE);
         if (!Success)
         {
-            DPRINT1("Failed to write dirty block to hive (index %lu)\n", 
BlockIndex);
+            DPRINT1("Failed to write dirty block to hive (index %u)\n", 
BlockIndex);
             return Fail;
         }
 
@@ -1489,7 +1489,7 @@ HvInitialize(
 
         default:
         {
-            DPRINT1("Invalid operation type (OperationType = %lu)\n", 
OperationType);
+            DPRINT1("Invalid operation type (OperationType = %u)\n", 
OperationType);
             return STATUS_INVALID_PARAMETER;
         }
     }

Reply via email to