Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 284c2fe

Browse files
committed
Klocwork fix: avoiding using memcpy
This patch reworks the code to avoid using the memcpy function. Signed-off-by: Thomas Cahuzac <[email protected]>
1 parent 89f1f17 commit 284c2fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/test-subsystem/TESTSubsystemBinary.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <stdlib.h>
3535
#include <assert.h>
3636
#include <algorithm>
37+
#include <AlwaysAssert.hpp>
3738
#include <Iterator.hpp>
3839
#include "TESTSubsystemBinary.h"
3940

@@ -51,9 +52,10 @@ std::string CTESTSubsystemBinary::toString(const void *pvValue, size_t size) con
5152
std::ostringstream strStream;
5253
uint32_t uiValue = 0;
5354

54-
assert(size <= sizeof(uiValue));
55+
ALWAYS_ASSERT(size <= sizeof(uiValue), "Wrong size '" << size << "' should be <= to '"
56+
<< sizeof(uiValue) << "'");
5557

56-
memcpy(&uiValue, pvValue, size);
58+
uiValue = *static_cast<const uint32_t *>(pvValue);
5759

5860
strStream << "0x" << std::hex << uiValue;
5961

0 commit comments

Comments
 (0)