From 41ce7deecf032d4fbf11dde7004f4a740ca0573b Mon Sep 17 00:00:00 2001 From: Dimitrios Stoupis <dimitris.apple@gmail.com> Date: Wed, 21 Nov 2018 12:25:58 +0000 Subject: [PATCH] Please cpp check! --- src/Services/MemMangService.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Services/MemMangService.cpp b/src/Services/MemMangService.cpp index 7a12696c..d5d0bb7e 100644 --- a/src/Services/MemMangService.cpp +++ b/src/Services/MemMangService.cpp @@ -27,13 +27,12 @@ void MemoryManagementService::RawDataMemoryManagement::loadRawData(Message &requ // Variable declaration uint8_t *readData = nullptr, *tempMemory = nullptr; // Pointer to store the received data - uint16_t allocatedLength = 0; // Length allocated for the readData array uint8_t memoryID = request.readEnum8(); // Read the memory ID from the request uint16_t iterationCount = request.readUint16(); // Get the iteration count if (memoryID == MemoryManagementService::MemoryID::RAM) { - for (std::size_t j =0; j < iterationCount; j++) { + for (std::size_t j = 0, allocatedLength = 0; j < iterationCount; j++) { uint64_t startAddress = request.readUint64(); // Start address of the memory uint16_t dataLength = request.readUint16(); // Data length to load @@ -73,7 +72,6 @@ void MemoryManagementService::RawDataMemoryManagement::dumpRawData(Message &requ // Variable declaration uint8_t *readData = nullptr, *tempMemory = nullptr;; // Pointer to store the read data - uint16_t allocatedLength = 0; // Length allocated for the readData array uint8_t memoryID = request.readEnum8(); // Read the memory ID from the request // todo: Add checks depending on the memory type @@ -85,7 +83,7 @@ void MemoryManagementService::RawDataMemoryManagement::dumpRawData(Message &requ report.appendUint16(iterationCount); // Iteration count // Iterate N times, as specified in the command message - for (std::size_t j = 0; j < iterationCount; j++) { + for (std::size_t j = 0, allocatedLength = 0; j < iterationCount; j++) { uint64_t startAddress = request.readUint64(); // Data length to read uint16_t readLength = request.readUint16(); // Start address for the memory read -- GitLab