gralloc: Refactor gralloc4.0 for some concerns in code review
There were some concerns raised in the intern code review process. Since
Qualcomm has merged their Gralloc4.0 changes into their codebase, the
patch created another standlane change to address the concerns within
the code review.
Bug: 141596968
Test: VtsHalGraphicsMapperV4_0TargetTest
Change-Id: Ie687557089064a6d02c7505f2024db6a23e003c8
(cherry picked from commit ce25d55c476a20e6cc130d3ba9500cd055b63392)
Change-Id: Ic397ae3874e68a7b5ba9315f31fbc098db21a800
diff --git a/gralloc/QtiMapper4.h b/gralloc/QtiMapper4.h
index caf8d12..7fa27b1 100644
--- a/gralloc/QtiMapper4.h
+++ b/gralloc/QtiMapper4.h
@@ -129,7 +129,7 @@
std::memcpy(&out[index], &magic_version, sizeof(magic_version));
index += sizeof(magic_version);
- out[index] = static_cast<uint8_t> (name_size);
+ std::memcpy(&out[index], &name_size, sizeof(name_size));
index += sizeof(name_size);
std::memcpy(&out[index], bd_info.name.c_str(), bd_info.name.size());
@@ -168,7 +168,8 @@
std::memcpy(&magic_version, &in[index], sizeof(magic_version));
index += sizeof(magic_version);
- uint64_t name_size = in[index];
+ uint64_t name_size;
+ std::memcpy(&name_size, &in[index], sizeof(name_size));
index += sizeof(name_size);
// The second check validates that the size and magic version are correct