Fix Parcel implementation 60/253860/3
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 18 Feb 2021 23:59:14 +0000 (08:59 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Thu, 11 Mar 2021 05:15:08 +0000 (05:15 +0000)
- Removes size data

Change-Id: I6d259af2467ffc09a0b041a8460b9b1884c2900b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
parcel/parcel.cc
tests/parcel_unittests/test_parcel.cc
tests/parcel_unittests/test_parcel_cpp.cc

index e310654..9171895 100644 (file)
@@ -76,7 +76,6 @@ void Parcel::Impl::WriteSize(uint32_t size) {
 
 template <typename T>
 void Parcel::Impl::Write(T d) {
-  WriteSize(sizeof(T));
   auto* p = reinterpret_cast<uint8_t*>(&d);
   std::copy(p, p + sizeof(T), std::back_inserter(data_));
 }
@@ -96,14 +95,7 @@ int Parcel::Impl::ReadSize(uint32_t* size) {
 
 template <typename T>
 int Parcel::Impl::Read(T* d) {
-  uint32_t size = 0;
-  int ret = ReadSize(&size);
-  if (ret != TIZEN_ERROR_NONE)
-    return ret;
-
-  if (size == 0 || size != sizeof(T))
-    return TIZEN_ERROR_ILLEGAL_BYTE_SEQ;
-
+  uint32_t size = sizeof(T);
   if (reader_ + size > data_.size())
     return TIZEN_ERROR_ILLEGAL_BYTE_SEQ;
 
index 65a895f..3fef107 100644 (file)
@@ -559,7 +559,7 @@ TEST_F(ParcelTest, parcel_get_raw_P) {
   ret = parcel_get_raw(GetHandle(), reinterpret_cast<void**>(&raw), &size);
   ASSERT_EQ(ret, PARCEL_ERROR_NONE);
   ASSERT_NE(raw, nullptr);
-  ASSERT_EQ(size, sizeof(uint32_t) + sizeof(int32_t));
+  ASSERT_EQ(size, sizeof(int32_t));
 }
 
 TEST_F(ParcelTest, parcel_get_raw_N) {
index 7a3488c..2c2f910 100644 (file)
@@ -211,7 +211,7 @@ TEST_F(ParcelCppTest, WriteBundle_AND_ReadBundle) {
 TEST_F(ParcelCppTest, GetRaw) {
   GetHandle().WriteInt32(0);
   auto& raw = GetHandle().GetRaw();
-  ASSERT_EQ(raw.size(), sizeof(uint32_t) + sizeof(int32_t));
+  ASSERT_EQ(raw.size(), sizeof(int32_t));
 }
 
 TEST_F(ParcelCppTest, ResetReader) {