IVGCVSW-4760 Change the offsets in the counter directory body_header to be from the...
authorFinn Williams <Finn.Williams@arm.com>
Thu, 30 Apr 2020 10:06:43 +0000 (11:06 +0100)
committerJim Flynn <jim.flynn@arm.com>
Thu, 30 Apr 2020 16:56:07 +0000 (16:56 +0000)
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: Ie5ef5e410f3b06f1c80c7c5ea2057f5008cf09ed

src/profiling/SendCounterPacket.cpp
src/profiling/test/ProfilingTestUtils.hpp
src/profiling/test/ProfilingTests.cpp
src/profiling/test/SendCounterPacketTests.cpp

index 1ef5440..00fddb6 100644 (file)
@@ -539,14 +539,15 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun
     using namespace boost::numeric;
 
     // Get the amount of data that needs to be put into the packet
-    uint16_t categoryCount    = counterDirectory.GetCategoryCount();
-    uint16_t deviceCount      = counterDirectory.GetDeviceCount();
-    uint16_t counterSetCount  = counterDirectory.GetCounterSetCount();
+    const uint16_t categoryCount    = counterDirectory.GetCategoryCount();
+    const uint16_t deviceCount      = counterDirectory.GetDeviceCount();
+    const uint16_t counterSetCount  = counterDirectory.GetCounterSetCount();
 
     // Utils
-    size_t uint32_t_size = sizeof(uint32_t);
-    size_t packetHeaderSize = 2u;
-    size_t bodyHeaderSize = 6u;
+    const size_t uint32_t_size = sizeof(uint32_t);
+    const size_t packetHeaderSize = 2u;
+    const size_t bodyHeaderSize = 6u;
+    const uint32_t bodyHeaderSizeBytes = bodyHeaderSize * uint32_t_size;
 
     // Initialize the offset for the pointer tables
     uint32_t pointerTableOffset = 0;
@@ -653,18 +654,18 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun
 
 
     // Calculate the length in words of the counter directory packet's data (excludes the packet header size)
-    size_t counterDirectoryPacketDataLength =
-            bodyHeaderSize +                 // The size of the body header
-            deviceRecordOffsets.size() +     // The size of the device records pointer table
-            counterSetRecordOffsets.size() + // The size of counter set pointer table
-            categoryRecordOffsets.size() +   // The size of category records pointer table
-            deviceRecordsSize +              // The total size of the device records
-            counterSetRecordsSize +          // The total size of the counter set records
-            categoryRecordsSize;             // The total size of the category records
+    const size_t counterDirectoryPacketDataLength =
+                 bodyHeaderSize +                 // The size of the body header
+                 deviceRecordOffsets.size() +     // The size of the device records pointer table
+                 counterSetRecordOffsets.size() + // The size of counter set pointer table
+                 categoryRecordOffsets.size() +   // The size of category records pointer table
+                 deviceRecordsSize +              // The total size of the device records
+                 counterSetRecordsSize +          // The total size of the counter set records
+                 categoryRecordsSize;             // The total size of the category records
 
     // Calculate the size in words of the counter directory packet (the data length plus the packet header size)
-    size_t counterDirectoryPacketSize = packetHeaderSize +                // The size of the packet header
-                                        counterDirectoryPacketDataLength; // The data length
+    const size_t counterDirectoryPacketSize = packetHeaderSize +                // The size of the packet header
+                                              counterDirectoryPacketDataLength; // The data length
 
 
     // Allocate the necessary space for the counter directory packet
@@ -701,39 +702,40 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun
     // Body header word 0:
     // 16:31 [16] device_records_count: number of entries in the device_records_pointer_table
     // 0:15  [16] reserved: all zeros
-    uint32_t bodyHeaderWord0 = static_cast<uint32_t>(deviceCount) << 16;
+    const uint32_t bodyHeaderWord0 = static_cast<uint32_t>(deviceCount) << 16;
 
     // Body header word 1:
     // 0:31 [32] device_records_pointer_table_offset: offset to the device_records_pointer_table
-    uint32_t bodyHeaderWord1 = 0; // The offset is always zero here, as the device record pointer table field is always
-                                  // the first item in the pool
+    const uint32_t bodyHeaderWord1 = bodyHeaderSizeBytes; // The offset is always the bodyHeaderSize,
+                                                          // as the device record pointer table field
+                                                          // is always the first item in the pool
 
     // Body header word 2:
     // 16:31 [16] counter_set_count: number of entries in the counter_set_pointer_table
     // 0:15  [16] reserved: all zeros
-    uint32_t bodyHeaderWord2 = static_cast<uint32_t>(counterSetCount) << 16;
+    const uint32_t bodyHeaderWord2 = static_cast<uint32_t>(counterSetCount) << 16;
 
     // Body header word 3:
     // 0:31 [32] counter_set_pointer_table_offset: offset to the counter_set_pointer_table
-    uint32_t bodyHeaderWord3 =
-            numeric_cast<uint32_t>(deviceRecordOffsets.size() * uint32_t_size); // The size of the device records
-                                                                                // pointer table
-
+    const uint32_t bodyHeaderWord3 =
+                   numeric_cast<uint32_t>(deviceRecordOffsets.size() * uint32_t_size // The size of the
+                                          + bodyHeaderSizeBytes);                    // device records pointer table
 
     // Body header word 4:
     // 16:31 [16] categories_count: number of entries in the categories_pointer_table
     // 0:15  [16] reserved: all zeros
-    uint32_t bodyHeaderWord4 = static_cast<uint32_t>(categoryCount) << 16;
+    const uint32_t bodyHeaderWord4 = static_cast<uint32_t>(categoryCount) << 16;
 
     // Body header word 3:
     // 0:31 [32] categories_pointer_table_offset: offset to the categories_pointer_table
-    uint32_t bodyHeaderWord5 =
-            numeric_cast<uint32_t>(deviceRecordOffsets.size() * uint32_t_size +     // The size of the device records
-                                   counterSetRecordOffsets.size() * uint32_t_size); // pointer table, plus the size of
-                                                                                    // the counter set pointer table
+    const uint32_t bodyHeaderWord5 =
+                   numeric_cast<uint32_t>(
+                       deviceRecordOffsets.size() * uint32_t_size +     // The size of the device records
+                       counterSetRecordOffsets.size() * uint32_t_size   // pointer table, plus the size of
+                       +  bodyHeaderSizeBytes);                         // the counter set pointer table
 
     // Create the body header
-    uint32_t bodyHeader[6]
+    const uint32_t bodyHeader[bodyHeaderSize]
     {
         bodyHeaderWord0, // device_records_count + reserved
         bodyHeaderWord1, // device_records_pointer_table_offset
index 16f1b0c..428ffa2 100644 (file)
@@ -17,6 +17,8 @@
 using namespace armnn;
 using namespace armnn::profiling;
 
+const static uint32_t bodyHeaderSize = 6;
+
 uint32_t GetStreamMetaDataPacketSize();
 
 inline unsigned int OffsetToNextWord(unsigned int numberOfBytes);
index 64646b4..bd6ae08 100644 (file)
@@ -2390,7 +2390,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2)
     RequestCounterDirectoryCommandHandler commandHandler(familyId, packetId, version, counterDirectory,
                                                          sendCounterPacket, sendTimelinePacket, profilingStateMachine);
     const uint32_t header = (packetId & 0x000003FF) << 16;
-    Packet packet(header);
+    const Packet packet(header);
 
     const Device* device = counterDirectory.RegisterDevice("deviceA", 1);
     BOOST_CHECK(device != nullptr);
@@ -2413,42 +2413,44 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2)
 
     auto readBuffer1 = mockBuffer1.GetReadableBuffer();
 
-    uint32_t header1Word0 = ReadUint32(readBuffer1, 0);
-    uint32_t header1Word1 = ReadUint32(readBuffer1, 4);
+    const uint32_t header1Word0 = ReadUint32(readBuffer1, 0);
+    const uint32_t header1Word1 = ReadUint32(readBuffer1, 4);
 
     BOOST_TEST(((header1Word0 >> 26) & 0x0000003F) == 0); // packet family
     BOOST_TEST(((header1Word0 >> 16) & 0x000003FF) == 2); // packet id
     BOOST_TEST(header1Word1 == 236);                      // data length
 
-    uint32_t bodyHeader1Word0      = ReadUint32(readBuffer1, 8);
-    uint32_t bodyHeader1Word1      = ReadUint32(readBuffer1, 12);
-    uint32_t bodyHeader1Word2      = ReadUint32(readBuffer1, 16);
-    uint32_t bodyHeader1Word3      = ReadUint32(readBuffer1, 20);
-    uint32_t bodyHeader1Word4      = ReadUint32(readBuffer1, 24);
-    uint32_t bodyHeader1Word5      = ReadUint32(readBuffer1, 28);
-    uint16_t deviceRecordCount     = numeric_cast<uint16_t>(bodyHeader1Word0 >> 16);
-    uint16_t counterSetRecordCount = numeric_cast<uint16_t>(bodyHeader1Word2 >> 16);
-    uint16_t categoryRecordCount   = numeric_cast<uint16_t>(bodyHeader1Word4 >> 16);
-    BOOST_TEST(deviceRecordCount == 1);     // device_records_count
-    BOOST_TEST(bodyHeader1Word1 == 0);      // device_records_pointer_table_offset
-    BOOST_TEST(counterSetRecordCount == 1); // counter_set_count
-    BOOST_TEST(bodyHeader1Word3 == 4);      // counter_set_pointer_table_offset
-    BOOST_TEST(categoryRecordCount == 1);   // categories_count
-    BOOST_TEST(bodyHeader1Word5 == 8);      // categories_pointer_table_offset
-
-    uint32_t deviceRecordOffset = ReadUint32(readBuffer1, 32);
+    const uint32_t bodyHeaderSizeBytes = bodyHeaderSize * sizeof(uint32_t);
+
+    const uint32_t bodyHeader1Word0      = ReadUint32(readBuffer1, 8);
+    const uint32_t bodyHeader1Word1      = ReadUint32(readBuffer1, 12);
+    const uint32_t bodyHeader1Word2      = ReadUint32(readBuffer1, 16);
+    const uint32_t bodyHeader1Word3      = ReadUint32(readBuffer1, 20);
+    const uint32_t bodyHeader1Word4      = ReadUint32(readBuffer1, 24);
+    const uint32_t bodyHeader1Word5      = ReadUint32(readBuffer1, 28);
+    const uint16_t deviceRecordCount     = numeric_cast<uint16_t>(bodyHeader1Word0 >> 16);
+    const uint16_t counterSetRecordCount = numeric_cast<uint16_t>(bodyHeader1Word2 >> 16);
+    const uint16_t categoryRecordCount   = numeric_cast<uint16_t>(bodyHeader1Word4 >> 16);
+    BOOST_TEST(deviceRecordCount == 1);                      // device_records_count
+    BOOST_TEST(bodyHeader1Word1 == 0 + bodyHeaderSizeBytes);      // device_records_pointer_table_offset
+    BOOST_TEST(counterSetRecordCount == 1);                  // counter_set_count
+    BOOST_TEST(bodyHeader1Word3 == 4 + bodyHeaderSizeBytes);      // counter_set_pointer_table_offset
+    BOOST_TEST(categoryRecordCount == 1);                    // categories_count
+    BOOST_TEST(bodyHeader1Word5 == 8 + bodyHeaderSizeBytes);      // categories_pointer_table_offset
+
+    const uint32_t deviceRecordOffset = ReadUint32(readBuffer1, 32);
     BOOST_TEST(deviceRecordOffset == 0);
 
-    uint32_t counterSetRecordOffset = ReadUint32(readBuffer1, 36);
+    const uint32_t counterSetRecordOffset = ReadUint32(readBuffer1, 36);
     BOOST_TEST(counterSetRecordOffset == 20);
 
-    uint32_t categoryRecordOffset = ReadUint32(readBuffer1, 40);
+    const uint32_t categoryRecordOffset = ReadUint32(readBuffer1, 40);
     BOOST_TEST(categoryRecordOffset == 44);
 
     auto readBuffer2 = mockBuffer2.GetReadableBuffer();
 
-    uint32_t header2Word0 = ReadUint32(readBuffer2, 0);
-    uint32_t header2Word1 = ReadUint32(readBuffer2, 4);
+    const uint32_t header2Word0 = ReadUint32(readBuffer2, 0);
+    const uint32_t header2Word1 = ReadUint32(readBuffer2, 4);
 
     // Timeline message directory packet
     BOOST_TEST(((header2Word0 >> 26) & 0x0000003F) == 1); // packet family
index 8321e88..5bfcd2c 100644 (file)
@@ -1229,52 +1229,52 @@ BOOST_AUTO_TEST_CASE(SendCounterDirectoryPacketTest2)
     auto readBuffer = mockBuffer.GetReadableBuffer();
 
     // Check the packet header
-    uint32_t packetHeaderWord0 = ReadUint32(readBuffer, 0);
-    uint32_t packetHeaderWord1 = ReadUint32(readBuffer, 4);
+    const uint32_t packetHeaderWord0 = ReadUint32(readBuffer, 0);
+    const uint32_t packetHeaderWord1 = ReadUint32(readBuffer, 4);
     BOOST_TEST(((packetHeaderWord0 >> 26) & 0x3F) == 0);  // packet_family
     BOOST_TEST(((packetHeaderWord0 >> 16) & 0x3FF) == 2); // packet_id
     BOOST_TEST(packetHeaderWord1 == 432);                 // data_length
 
     // Check the body header
-    uint32_t bodyHeaderWord0 = ReadUint32(readBuffer,  8);
-    uint32_t bodyHeaderWord1 = ReadUint32(readBuffer, 12);
-    uint32_t bodyHeaderWord2 = ReadUint32(readBuffer, 16);
-    uint32_t bodyHeaderWord3 = ReadUint32(readBuffer, 20);
-    uint32_t bodyHeaderWord4 = ReadUint32(readBuffer, 24);
-    uint32_t bodyHeaderWord5 = ReadUint32(readBuffer, 28);
-    uint16_t deviceRecordCount     = static_cast<uint16_t>(bodyHeaderWord0 >> 16);
-    uint16_t counterSetRecordCount = static_cast<uint16_t>(bodyHeaderWord2 >> 16);
-    uint16_t categoryRecordCount   = static_cast<uint16_t>(bodyHeaderWord4 >> 16);
-    BOOST_TEST(deviceRecordCount == 2);     // device_records_count
-    BOOST_TEST(bodyHeaderWord1 == 0);       // device_records_pointer_table_offset
-    BOOST_TEST(counterSetRecordCount == 1); // counter_set_count
-    BOOST_TEST(bodyHeaderWord3 == 8);       // counter_set_pointer_table_offset
-    BOOST_TEST(categoryRecordCount == 2);   // categories_count
-    BOOST_TEST(bodyHeaderWord5 == 12);      // categories_pointer_table_offset
+    const uint32_t bodyHeaderWord0 = ReadUint32(readBuffer,  8);
+    const uint32_t bodyHeaderWord1 = ReadUint32(readBuffer, 12);
+    const uint32_t bodyHeaderWord2 = ReadUint32(readBuffer, 16);
+    const uint32_t bodyHeaderWord3 = ReadUint32(readBuffer, 20);
+    const uint32_t bodyHeaderWord4 = ReadUint32(readBuffer, 24);
+    const uint32_t bodyHeaderWord5 = ReadUint32(readBuffer, 28);
+    const uint16_t deviceRecordCount     = static_cast<uint16_t>(bodyHeaderWord0 >> 16);
+    const uint16_t counterSetRecordCount = static_cast<uint16_t>(bodyHeaderWord2 >> 16);
+    const uint16_t categoryRecordCount   = static_cast<uint16_t>(bodyHeaderWord4 >> 16);
+    BOOST_TEST(deviceRecordCount == 2);                      // device_records_count
+    BOOST_TEST(bodyHeaderWord1 == bodyHeaderSize * 4);           // device_records_pointer_table_offset
+    BOOST_TEST(counterSetRecordCount == 1);                  // counter_set_count
+    BOOST_TEST(bodyHeaderWord3 == 8 + bodyHeaderSize * 4);       // counter_set_pointer_table_offset
+    BOOST_TEST(categoryRecordCount == 2);                    // categories_count
+    BOOST_TEST(bodyHeaderWord5 == 12 + bodyHeaderSize * 4);      // categories_pointer_table_offset
 
     // Check the device records pointer table
-    uint32_t deviceRecordOffset0 = ReadUint32(readBuffer, 32);
-    uint32_t deviceRecordOffset1 = ReadUint32(readBuffer, 36);
+    const uint32_t deviceRecordOffset0 = ReadUint32(readBuffer, 32);
+    const uint32_t deviceRecordOffset1 = ReadUint32(readBuffer, 36);
     BOOST_TEST(deviceRecordOffset0 ==  0); // Device record offset for "device1"
     BOOST_TEST(deviceRecordOffset1 == 20); // Device record offset for "device2"
 
     // Check the counter set pointer table
-    uint32_t counterSetRecordOffset0 = ReadUint32(readBuffer, 40);
+    const uint32_t counterSetRecordOffset0 = ReadUint32(readBuffer, 40);
     BOOST_TEST(counterSetRecordOffset0 == 40); // Counter set record offset for "counterset1"
 
     // Check the category pointer table
-    uint32_t categoryRecordOffset0 = ReadUint32(readBuffer, 44);
-    uint32_t categoryRecordOffset1 = ReadUint32(readBuffer, 48);
+    const uint32_t categoryRecordOffset0 = ReadUint32(readBuffer, 44);
+    const uint32_t categoryRecordOffset1 = ReadUint32(readBuffer, 48);
     BOOST_TEST(categoryRecordOffset0 ==  64); // Category record offset for "category1"
     BOOST_TEST(categoryRecordOffset1 == 168); // Category record offset for "category2"
 
     // Get the device record pool offset
-    uint32_t uint32_t_size = sizeof(uint32_t);
-    uint32_t packetBodyPoolOffset = 2u * uint32_t_size +                    // packet_header
-                                    6u * uint32_t_size +                    // body_header
-                                    deviceRecordCount * uint32_t_size +     // Size of device_records_pointer_table
-                                    counterSetRecordCount * uint32_t_size + // Size of counter_set_pointer_table
-                                    categoryRecordCount * uint32_t_size;    // Size of categories_pointer_table
+    const uint32_t uint32_t_size = sizeof(uint32_t);
+    const uint32_t packetBodyPoolOffset = 2u * uint32_t_size +                   // packet_header
+                                          bodyHeaderWord1 +                      // body_header
+                                          deviceRecordCount * uint32_t_size +    // Size of device_records_pointer_table
+                                          counterSetRecordCount * uint32_t_size  // Size of counter_set_pointer_table
+                                          + categoryRecordCount * uint32_t_size; // Size of categories_pointer_table
 
     // Device record structure/collection used for testing
     struct DeviceRecord
@@ -1286,22 +1286,21 @@ BOOST_AUTO_TEST_CASE(SendCounterDirectoryPacketTest2)
         std::string name;
     };
     std::vector<DeviceRecord> deviceRecords;
-    uint32_t deviceRecordsPointerTableOffset = 2u * uint32_t_size + // packet_header
-                                               6u * uint32_t_size + // body_header
-                                               bodyHeaderWord1;     // device_records_pointer_table_offset
+    const uint32_t deviceRecordsPointerTableOffset = 2u * uint32_t_size + // packet_header
+                                                     bodyHeaderWord1;     // device_records_pointer_table_offset
 
     const unsigned char* readData = readBuffer->GetReadableData();
 
     for (uint32_t i = 0; i < deviceRecordCount; i++)
     {
         // Get the device record offset
-        uint32_t deviceRecordOffset = ReadUint32(readBuffer, deviceRecordsPointerTableOffset + i * uint32_t_size);
+        const uint32_t deviceRecordOffset = ReadUint32(readBuffer, deviceRecordsPointerTableOffset + i * uint32_t_size);
 
         // Collect the data for the device record
-        uint32_t deviceRecordWord0 = ReadUint32(readBuffer,
-                                                packetBodyPoolOffset + deviceRecordOffset + 0 * uint32_t_size);
-        uint32_t deviceRecordWord1 = ReadUint32(readBuffer,
-                                                packetBodyPoolOffset + deviceRecordOffset + 1 * uint32_t_size);
+        const uint32_t deviceRecordWord0 = ReadUint32(readBuffer,
+                                                      packetBodyPoolOffset + deviceRecordOffset + 0 * uint32_t_size);
+        const uint32_t deviceRecordWord1 = ReadUint32(readBuffer,
+                                                      packetBodyPoolOffset + deviceRecordOffset + 1 * uint32_t_size);
         DeviceRecord deviceRecord;
         deviceRecord.uid = static_cast<uint16_t>(deviceRecordWord0 >> 16); // uid
         deviceRecord.cores = static_cast<uint16_t>(deviceRecordWord0);     // cores
@@ -1345,20 +1344,21 @@ BOOST_AUTO_TEST_CASE(SendCounterDirectoryPacketTest2)
         std::string name;
     };
     std::vector<CounterSetRecord> counterSetRecords;
-    uint32_t counterSetRecordsPointerTableOffset = 2u * uint32_t_size + // packet_header
-                                                   6u * uint32_t_size + // body_header
-                                                   bodyHeaderWord3;     // counter_set_pointer_table_offset
+    const uint32_t counterSetRecordsPointerTableOffset = 2u * uint32_t_size + // packet_header
+                                                         bodyHeaderWord3;     // counter_set_pointer_table_offset
     for (uint32_t i = 0; i < counterSetRecordCount; i++)
     {
         // Get the counter set record offset
-        uint32_t counterSetRecordOffset = ReadUint32(readBuffer,
-                                                     counterSetRecordsPointerTableOffset + i * uint32_t_size);
+        const uint32_t counterSetRecordOffset = ReadUint32(readBuffer,
+                                                           counterSetRecordsPointerTableOffset + i * uint32_t_size);
 
         // Collect the data for the counter set record
-        uint32_t counterSetRecordWord0 = ReadUint32(readBuffer,
-                                                    packetBodyPoolOffset + counterSetRecordOffset + 0 * uint32_t_size);
-        uint32_t counterSetRecordWord1 = ReadUint32(readBuffer,
-                                                    packetBodyPoolOffset + counterSetRecordOffset + 1 * uint32_t_size);
+        const uint32_t counterSetRecordWord0 = ReadUint32(readBuffer,
+                                                          packetBodyPoolOffset + counterSetRecordOffset +
+                                                          0 * uint32_t_size);
+        const uint32_t counterSetRecordWord1 = ReadUint32(readBuffer,
+                                                          packetBodyPoolOffset + counterSetRecordOffset +
+                                                          1 * uint32_t_size);
         CounterSetRecord counterSetRecord;
         counterSetRecord.uid = static_cast<uint16_t>(counterSetRecordWord0 >> 16); // uid
         counterSetRecord.count = static_cast<uint16_t>(counterSetRecordWord0);     // count
@@ -1424,21 +1424,24 @@ BOOST_AUTO_TEST_CASE(SendCounterDirectoryPacketTest2)
         std::vector<EventRecord> event_records;
     };
     std::vector<CategoryRecord> categoryRecords;
-    uint32_t categoryRecordsPointerTableOffset = 2u * uint32_t_size + // packet_header
-                                                 6u * uint32_t_size + // body_header
-                                                 bodyHeaderWord5;     // categories_pointer_table_offset
+    const uint32_t categoryRecordsPointerTableOffset = 2u * uint32_t_size + // packet_header
+                                                       bodyHeaderWord5;    // categories_pointer_table_offset
     for (uint32_t i = 0; i < categoryRecordCount; i++)
     {
         // Get the category record offset
-        uint32_t categoryRecordOffset = ReadUint32(readBuffer, categoryRecordsPointerTableOffset + i * uint32_t_size);
+        const uint32_t categoryRecordOffset = ReadUint32(readBuffer, categoryRecordsPointerTableOffset +
+                                                         i * uint32_t_size);
 
         // Collect the data for the category record
-        uint32_t categoryRecordWord1 = ReadUint32(readBuffer,
-                                                  packetBodyPoolOffset + categoryRecordOffset + 0 * uint32_t_size);
-        uint32_t categoryRecordWord2 = ReadUint32(readBuffer,
-                                                  packetBodyPoolOffset + categoryRecordOffset + 1 * uint32_t_size);
-        uint32_t categoryRecordWord3 = ReadUint32(readBuffer,
-                                                  packetBodyPoolOffset + categoryRecordOffset + 2 * uint32_t_size);
+        const uint32_t categoryRecordWord1 = ReadUint32(readBuffer,
+                                                        packetBodyPoolOffset + categoryRecordOffset +
+                                                        0 * uint32_t_size);
+        const uint32_t categoryRecordWord2 = ReadUint32(readBuffer,
+                                                        packetBodyPoolOffset + categoryRecordOffset +
+                                                        1 * uint32_t_size);
+        const uint32_t categoryRecordWord3 = ReadUint32(readBuffer,
+                                                        packetBodyPoolOffset + categoryRecordOffset +
+                                                        2 * uint32_t_size);
         CategoryRecord categoryRecord;
         categoryRecord.event_count = static_cast<uint16_t>(categoryRecordWord1 >> 16); // event_count
         categoryRecord.event_pointer_table_offset = categoryRecordWord2;               // event_pointer_table_offset
@@ -1477,20 +1480,27 @@ BOOST_AUTO_TEST_CASE(SendCounterDirectoryPacketTest2)
             categoryRecord.event_pointer_table[eventIndex] = eventRecordOffset;
 
             // Collect the data for the event record
-            uint32_t eventRecordWord0  = ReadUint32(readBuffer,
-                                                    categoryRecordPoolOffset + eventRecordOffset + 0 * uint32_t_size);
-            uint32_t eventRecordWord1  = ReadUint32(readBuffer,
-                                                    categoryRecordPoolOffset + eventRecordOffset + 1 * uint32_t_size);
-            uint32_t eventRecordWord2  = ReadUint32(readBuffer,
-                                                    categoryRecordPoolOffset + eventRecordOffset + 2 * uint32_t_size);
-            uint64_t eventRecordWord34 = ReadUint64(readBuffer,
-                                                    categoryRecordPoolOffset + eventRecordOffset + 3 * uint32_t_size);
-            uint32_t eventRecordWord5 =  ReadUint32(readBuffer,
-                                                    categoryRecordPoolOffset + eventRecordOffset + 5 * uint32_t_size);
-            uint32_t eventRecordWord6 = ReadUint32(readBuffer,
-                                                   categoryRecordPoolOffset + eventRecordOffset + 6 * uint32_t_size);
-            uint32_t eventRecordWord7 = ReadUint32(readBuffer,
-                                                   categoryRecordPoolOffset + eventRecordOffset + 7 * uint32_t_size);
+            const uint32_t eventRecordWord0  = ReadUint32(readBuffer,
+                                                          categoryRecordPoolOffset + eventRecordOffset +
+                                                          0 * uint32_t_size);
+            const uint32_t eventRecordWord1  = ReadUint32(readBuffer,
+                                                          categoryRecordPoolOffset + eventRecordOffset +
+                                                          1 * uint32_t_size);
+            const uint32_t eventRecordWord2  = ReadUint32(readBuffer,
+                                                          categoryRecordPoolOffset + eventRecordOffset +
+                                                          2 * uint32_t_size);
+            const uint64_t eventRecordWord34 = ReadUint64(readBuffer,
+                                                          categoryRecordPoolOffset + eventRecordOffset +
+                                                          3 * uint32_t_size);
+            const uint32_t eventRecordWord5 =  ReadUint32(readBuffer,
+                                                          categoryRecordPoolOffset + eventRecordOffset +
+                                                          5 * uint32_t_size);
+            const uint32_t eventRecordWord6 = ReadUint32(readBuffer,
+                                                         categoryRecordPoolOffset + eventRecordOffset +
+                                                         6 * uint32_t_size);
+            const uint32_t eventRecordWord7 = ReadUint32(readBuffer,
+                                                         categoryRecordPoolOffset + eventRecordOffset +
+                                                         7 * uint32_t_size);
             EventRecord eventRecord;
             eventRecord.counter_uid = static_cast<uint16_t>(eventRecordWord0);                     // counter_uid
             eventRecord.max_counter_uid = static_cast<uint16_t>(eventRecordWord0 >> 16);           // max_counter_uid