Use bundle_encode_raw in rpc-port-parcel 65/316465/2
authorjh9216.park <jh9216.park@samsung.com>
Thu, 22 Aug 2024 02:23:48 +0000 (22:23 -0400)
committerjh9216.park <jh9216.park@samsung.com>
Wed, 28 Aug 2024 00:30:33 +0000 (20:30 -0400)
- bundle_encode_raw does not use Base64 encoder
- It it faster then bundle_encode
- Requires
  https://review.tizen.org/gerrit/#/c/platform/core/base/bundle/+/316457/

Change-Id: Ie9b20b43b795064c129e865683ae58a0a691a881
Signed-off-by: jh9216.park <jh9216.park@samsung.com>
src/rpc-port/rpc-port-parcel.cc

index c2710c6597e9b87511fcdebafedd7c599df6df2f..c6440fe038ccf3334cf2265f3a07279afc7a32d4 100644 (file)
 
 #include "include/rpc-port-parcel.h"
 
-#include <parcel.hh>
+#include <bundle_internal.h>
 #include <stdint.h>
 #include <string.h>
 
 #include <memory>
+#include <parcel.hh>
 
 #include "log-private.hh"
 #include "parcel-internal.hh"
 #include "port-internal.hh"
 
-#define MAX_PARCEL_SIZE   (1024 * 1024 * 10)
+#define MAX_PARCEL_SIZE (1024 * 1024 * 10)
 
 #undef RPC_API
 #define RPC_API extern "C" __attribute__((visibility("default")))
 using namespace rpc_port;
 
 RPC_API int rpc_port_parcel_create(rpc_port_parcel_h* h) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = new (std::nothrow) internal::Parcel();
-  if (parcel == nullptr)
-    return RPC_PORT_ERROR_OUT_OF_MEMORY;
+  if (parcel == nullptr) return RPC_PORT_ERROR_OUT_OF_MEMORY;
 
   *h = static_cast<rpc_port_parcel_h>(parcel);
   return RPC_PORT_ERROR_NONE;
 }
 
 RPC_API int rpc_port_parcel_create_from_port(rpc_port_parcel_h* h,
-    rpc_port_h port) {
+                                             rpc_port_h port) {
   int len;
   unsigned char* buf;
 
-  if (h == nullptr || port == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || port == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   internal::Port* pt = static_cast<internal::Port*>(port);
   {
     std::lock_guard<std::recursive_mutex> lock(pt->GetReadMutex());
     int ret = rpc_port_read(port, &len, 4);
-    if (ret != 0)
-      return ret;
+    if (ret != 0) return ret;
 
-    if (len <= 0 || len > MAX_PARCEL_SIZE)
-      return RPC_PORT_ERROR_IO_ERROR;
+    if (len <= 0 || len > MAX_PARCEL_SIZE) return RPC_PORT_ERROR_IO_ERROR;
 
     buf = static_cast<unsigned char*>(malloc(len));
     if (buf == nullptr) {
-      _E("Out of memory");  // LCOV_EXCL_LINE
+      _E("Out of memory");             // LCOV_EXCL_LINE
       return RPC_PORT_ERROR_IO_ERROR;  // LCOV_EXCL_LINE
     }
 
     ret = rpc_port_read(port, buf, len);
     if (ret != 0) {
-      free(buf);  // LCOV_EXCL_LINE
+      free(buf);   // LCOV_EXCL_LINE
       return ret;  // LCOV_EXCL_LINE
     }
   }
@@ -92,35 +88,30 @@ RPC_API int rpc_port_parcel_create_from_port(rpc_port_parcel_h* h,
 }
 
 RPC_API int rpc_port_parcel_send(rpc_port_parcel_h h, rpc_port_h port) {
-  if (h == nullptr || port == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || port == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   tizen_base::Parcel raw_parcel;
   raw_parcel.WriteParcelable(*parcel);
   void* raw = reinterpret_cast<void*>(raw_parcel.GetData());
   uint32_t len = static_cast<uint32_t>(raw_parcel.GetDataSize());
-  if (len <= 0)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (len <= 0) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   internal::Port* pt = static_cast<internal::Port*>(port);
   {
     std::lock_guard<std::recursive_mutex> lock(pt->GetWriteMutex());
     int ret = rpc_port_write(port, &len, sizeof(len));
-    if (ret != 0)
-      return ret;
+    if (ret != 0) return ret;
 
     ret = rpc_port_write(port, raw, len);
-    if (ret != 0)
-      return ret;
+    if (ret != 0) return ret;
   }
 
   return RPC_PORT_ERROR_NONE;
 }
 
 RPC_API int rpc_port_parcel_destroy(rpc_port_parcel_h h) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   delete parcel;
@@ -128,8 +119,7 @@ RPC_API int rpc_port_parcel_destroy(rpc_port_parcel_h h) {
 }
 
 RPC_API int rpc_port_parcel_write_byte(rpc_port_parcel_h h, char b) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   parcel_write_byte(parcel->GetHandle(), b);
@@ -137,8 +127,7 @@ RPC_API int rpc_port_parcel_write_byte(rpc_port_parcel_h h, char b) {
 }
 
 RPC_API int rpc_port_parcel_write_int16(rpc_port_parcel_h h, short i) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   parcel_write_int16(parcel->GetHandle(), i);
@@ -146,8 +135,7 @@ RPC_API int rpc_port_parcel_write_int16(rpc_port_parcel_h h, short i) {
 }
 
 RPC_API int rpc_port_parcel_write_int32(rpc_port_parcel_h h, int i) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   parcel_write_int32(parcel->GetHandle(), i);
@@ -155,8 +143,7 @@ RPC_API int rpc_port_parcel_write_int32(rpc_port_parcel_h h, int i) {
 }
 
 RPC_API int rpc_port_parcel_write_int64(rpc_port_parcel_h h, long long i) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   parcel_write_int64(parcel->GetHandle(), i);
@@ -164,8 +151,7 @@ RPC_API int rpc_port_parcel_write_int64(rpc_port_parcel_h h, long long i) {
 }
 
 RPC_API int rpc_port_parcel_write_float(rpc_port_parcel_h h, float f) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   parcel_write_float(parcel->GetHandle(), f);
@@ -173,8 +159,7 @@ RPC_API int rpc_port_parcel_write_float(rpc_port_parcel_h h, float f) {
 }
 
 RPC_API int rpc_port_parcel_write_double(rpc_port_parcel_h h, double d) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   parcel_write_double(parcel->GetHandle(), d);
@@ -182,8 +167,7 @@ RPC_API int rpc_port_parcel_write_double(rpc_port_parcel_h h, double d) {
 }
 
 RPC_API int rpc_port_parcel_write_string(rpc_port_parcel_h h, const char* str) {
-  if (h == nullptr || str == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || str == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   parcel_write_string(parcel->GetHandle(), str);
@@ -191,8 +175,7 @@ RPC_API int rpc_port_parcel_write_string(rpc_port_parcel_h h, const char* str) {
 }
 
 RPC_API int rpc_port_parcel_write_bool(rpc_port_parcel_h h, bool b) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   parcel_write_bool(parcel->GetHandle(), b);
@@ -200,22 +183,23 @@ RPC_API int rpc_port_parcel_write_bool(rpc_port_parcel_h h, bool b) {
 }
 
 RPC_API int rpc_port_parcel_write_bundle(rpc_port_parcel_h h, bundle* b) {
-  if (h == nullptr || b == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || b == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   bundle_raw* raw = nullptr;
   int len = 0;
-  bundle_encode(b, &raw, &len);
-  auto ptr = std::unique_ptr<bundle_raw, decltype(std::free)*>(raw, std::free);
+  bundle_encode_raw(b, &raw, &len);
+  auto ptr =
+      std::unique_ptr<bundle_raw*, decltype(bundle_free_encoded_rawdata)*>(
+          &raw, bundle_free_encoded_rawdata);
 
   auto* parcel = static_cast<internal::Parcel*>(h);
-  parcel_write_string(parcel->GetHandle(), reinterpret_cast<char*>(raw));
+  parcel_write_int32(parcel->GetHandle(), len);
+  parcel_burst_write(parcel->GetHandle(), raw, len);
   return RPC_PORT_ERROR_NONE;
 }
 
 RPC_API int rpc_port_parcel_write_array_count(rpc_port_parcel_h h, int count) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   parcel_write_int32(parcel->GetHandle(), count);
@@ -223,20 +207,19 @@ RPC_API int rpc_port_parcel_write_array_count(rpc_port_parcel_h h, int count) {
 }
 
 RPC_API int rpc_port_parcel_write(rpc_port_parcel_h h,
-    rpc_port_parcelable_t* parcelable, void* data) {
+                                  rpc_port_parcelable_t* parcelable,
+                                  void* data) {
   if (parcelable == nullptr || parcelable->to == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   parcelable->to(h, data);
   return RPC_PORT_ERROR_NONE;
 }
 
 RPC_API int rpc_port_parcel_read_byte(rpc_port_parcel_h h, char* b) {
-  if (h == nullptr || b == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || b == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   int ret = parcel_read_byte(parcel->GetHandle(), b);
@@ -247,8 +230,7 @@ RPC_API int rpc_port_parcel_read_byte(rpc_port_parcel_h h, char* b) {
 }
 
 RPC_API int rpc_port_parcel_read_int16(rpc_port_parcel_h h, short* i) {
-  if (h == nullptr || i == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || i == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   int ret = parcel_read_int16(parcel->GetHandle(), i);
@@ -259,8 +241,7 @@ RPC_API int rpc_port_parcel_read_int16(rpc_port_parcel_h h, short* i) {
 }
 
 RPC_API int rpc_port_parcel_read_int32(rpc_port_parcel_h h, int* i) {
-  if (h == nullptr || i == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || i == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   int ret = parcel_read_int32(parcel->GetHandle(), i);
@@ -271,8 +252,7 @@ RPC_API int rpc_port_parcel_read_int32(rpc_port_parcel_h h, int* i) {
 }
 
 RPC_API int rpc_port_parcel_read_int64(rpc_port_parcel_h h, long long* i) {
-  if (h == nullptr || i == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || i == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   int64_t val = 0;
@@ -285,8 +265,7 @@ RPC_API int rpc_port_parcel_read_int64(rpc_port_parcel_h h, long long* i) {
 }
 
 RPC_API int rpc_port_parcel_read_float(rpc_port_parcel_h h, float* f) {
-  if (h == nullptr || f == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || f == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   int ret = parcel_read_float(parcel->GetHandle(), f);
@@ -297,8 +276,7 @@ RPC_API int rpc_port_parcel_read_float(rpc_port_parcel_h h, float* f) {
 }
 
 RPC_API int rpc_port_parcel_read_double(rpc_port_parcel_h h, double* d) {
-  if (h == nullptr || d == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || d == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   int ret = parcel_read_double(parcel->GetHandle(), d);
@@ -309,22 +287,20 @@ RPC_API int rpc_port_parcel_read_double(rpc_port_parcel_h h, double* d) {
 }
 
 RPC_API int rpc_port_parcel_read_string(rpc_port_parcel_h h, char** str) {
-  if (h == nullptr || str == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || str == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   int ret = parcel_read_string(parcel->GetHandle(), str);
   if (ret != PARCEL_ERROR_NONE) {
     _E("parcel_read_string() is failed. error(%d)", ret);  // LCOV_EXCL_LINE
-    *str = strdup("");  // LCOV_EXCL_LINE
+    *str = strdup("");                                     // LCOV_EXCL_LINE
   }
 
   return RPC_PORT_ERROR_NONE;
 }
 
 RPC_API int rpc_port_parcel_read_bool(rpc_port_parcel_h h, bool* b) {
-  if (h == nullptr || b == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || b == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   int ret = parcel_read_bool(parcel->GetHandle(), b);
@@ -335,26 +311,31 @@ RPC_API int rpc_port_parcel_read_bool(rpc_port_parcel_h h, bool* b) {
 }
 
 RPC_API int rpc_port_parcel_read_bundle(rpc_port_parcel_h h, bundle** b) {
-  if (h == nullptr || b == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || b == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
-  char* raw = nullptr;
-  int ret = parcel_read_string(parcel->GetHandle(), &raw);
+  int len = 0;
+  int ret = parcel_read_int32(parcel->GetHandle(), &len);
   if (ret != 0) {
-    _E("parcel_read_string() is failed. error(%d)", ret);  // LCOV_EXCL_LINE
-    *b = bundle_create();  // LCOV_EXCL_LINE
+    _E("parcel_read_int32() failed. error(%d)", ret);  // LCOV_EXCL_LINE
+    *b = bundle_create();                              // LCOV_EXCL_LINE
+    return RPC_PORT_ERROR_NONE;
+  }
+
+  void* raw = nullptr;
+  ret = parcel_read_ptr(parcel->GetHandle(), &raw, len);
+  if (ret != 0 || raw == nullptr) {
+    _E("parcel_read_ptr() failed.");  // LCOV_EXCL_LINE
+    *b = bundle_create();             // LCOV_EXCL_LINE
   } else {
-    *b = bundle_decode(reinterpret_cast<bundle_raw*>(raw), strlen(raw));
-    std::free(raw);
+    *b = bundle_decode_raw(static_cast<bundle_raw*>(raw), len);
   }
 
   return RPC_PORT_ERROR_NONE;
 }
 
 RPC_API int rpc_port_parcel_read_array_count(rpc_port_parcel_h h, int* count) {
-  if (h == nullptr || count == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr || count == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   int ret = parcel_read_int32(parcel->GetHandle(), count);
@@ -365,26 +346,25 @@ RPC_API int rpc_port_parcel_read_array_count(rpc_port_parcel_h h, int* count) {
 }
 
 RPC_API int rpc_port_parcel_read(rpc_port_parcel_h h,
-    rpc_port_parcelable_t* parcelable, void* data) {
+                                 rpc_port_parcelable_t* parcelable,
+                                 void* data) {
   if (parcelable == nullptr || parcelable->from == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   parcelable->from(h, data);
   return RPC_PORT_ERROR_NONE;
 }
 
-RPC_API int rpc_port_parcel_burst_read(rpc_port_parcel_h h, unsigned char *buf,
-    unsigned int size) {
-  if (h == nullptr || buf == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+RPC_API int rpc_port_parcel_burst_read(rpc_port_parcel_h h, unsigned char* buf,
+                                       unsigned int size) {
+  if (h == nullptr || buf == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   uint32_t valid_size = size & UINT32_MAX;
   int ret = parcel_burst_read(parcel->GetHandle(), static_cast<void*>(buf),
-      valid_size);
+                              valid_size);
   if (ret != PARCEL_ERROR_NONE)
     _E("parcel_read() is failed. error(%d)", ret);  // LCOV_EXCL_LINE
 
@@ -392,20 +372,19 @@ RPC_API int rpc_port_parcel_burst_read(rpc_port_parcel_h h, unsigned char *buf,
 }
 
 RPC_API int rpc_port_parcel_burst_write(rpc_port_parcel_h h,
-    const unsigned char *buf, unsigned int size) {
-  if (h == nullptr || buf == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+                                        const unsigned char* buf,
+                                        unsigned int size) {
+  if (h == nullptr || buf == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   uint32_t valid_size = size & UINT32_MAX;
   parcel_burst_write(parcel->GetHandle(), static_cast<const void*>(buf),
-      valid_size);
+                     valid_size);
   return RPC_PORT_ERROR_NONE;
 }
 
 RPC_API int rpc_port_parcel_reset_reader(rpc_port_parcel_h h) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   parcel_reset_reader(parcel->GetHandle());
@@ -413,9 +392,8 @@ RPC_API int rpc_port_parcel_reset_reader(rpc_port_parcel_h h) {
 }
 
 RPC_API int rpc_port_parcel_to_array(rpc_port_parcel_h h, void** array,
-    unsigned int* size) {
-  if (h == nullptr || !array || !size)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+                                     unsigned int* size) {
+  if (h == nullptr || !array || !size) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   tizen_base::Parcel raw_parcel;
@@ -428,8 +406,7 @@ RPC_API int rpc_port_parcel_to_array(rpc_port_parcel_h h, void** array,
   }
 
   void* array_ptr = malloc(raw_size);
-  if (array_ptr == nullptr)
-    return RPC_PORT_ERROR_OUT_OF_MEMORY;
+  if (array_ptr == nullptr) return RPC_PORT_ERROR_OUT_OF_MEMORY;
 
   memcpy(array_ptr, raw, raw_size);
   *array = array_ptr;
@@ -438,7 +415,7 @@ RPC_API int rpc_port_parcel_to_array(rpc_port_parcel_h h, void** array,
 }
 
 RPC_API int rpc_port_parcel_from_array(rpc_port_parcel_h h, const void* array,
-    unsigned int size) {
+                                       unsigned int size) {
   if (h == nullptr || array == nullptr || size == 0)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
@@ -450,14 +427,13 @@ RPC_API int rpc_port_parcel_from_array(rpc_port_parcel_h h, const void* array,
 }
 
 RPC_API int rpc_port_parcel_get_header(rpc_port_parcel_h h,
-    rpc_port_parcel_header_h* header) {
+                                       rpc_port_parcel_header_h* header) {
   if (h == nullptr || header == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = static_cast<internal::Parcel*>(h);
   auto* parcel_header = parcel->GetParcelHeader();
-  if (parcel_header == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (parcel_header == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   *header = reinterpret_cast<rpc_port_parcel_header_h>(
       const_cast<internal::ParcelHeader*>(parcel_header));
@@ -465,7 +441,7 @@ RPC_API int rpc_port_parcel_get_header(rpc_port_parcel_h h,
 }
 
 RPC_API int rpc_port_parcel_header_set_tag(rpc_port_parcel_header_h header,
-    const char* tag) {
+                                           const char* tag) {
   if (header == nullptr || tag == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
@@ -475,7 +451,7 @@ RPC_API int rpc_port_parcel_header_set_tag(rpc_port_parcel_header_h header,
 }
 
 RPC_API int rpc_port_parcel_header_get_tag(rpc_port_parcel_header_h header,
-    char** tag) {
+                                           char** tag) {
   if (header == nullptr || tag == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
@@ -483,16 +459,14 @@ RPC_API int rpc_port_parcel_header_get_tag(rpc_port_parcel_header_h header,
   const std::string& raw_tag = parcel_header->GetTag();
 
   *tag = strdup(raw_tag.c_str());
-  if (*tag == nullptr)
-    return RPC_PORT_ERROR_OUT_OF_MEMORY;  // LCOV_EXCL_LINE
+  if (*tag == nullptr) return RPC_PORT_ERROR_OUT_OF_MEMORY;  // LCOV_EXCL_LINE
 
   return RPC_PORT_ERROR_NONE;
 }
 
 RPC_API int rpc_port_parcel_header_set_seq_num(rpc_port_parcel_header_h header,
-    int seq_num) {
-  if (header == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+                                               int seq_num) {
+  if (header == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel_header = static_cast<internal::ParcelHeader*>(header);
   parcel_header->SetSeqNum(seq_num);
@@ -500,7 +474,7 @@ RPC_API int rpc_port_parcel_header_set_seq_num(rpc_port_parcel_header_h header,
 }
 
 RPC_API int rpc_port_parcel_header_get_seq_num(rpc_port_parcel_header_h header,
-    int* seq_num) {
+                                               int* seq_num) {
   if (header == nullptr || seq_num == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
@@ -520,7 +494,7 @@ RPC_API int rpc_port_parcel_header_get_timestamp(
 }
 
 RPC_API int rpc_port_parcel_get_raw(rpc_port_parcel_h h, void** raw,
-    unsigned int* size) {
+                                    unsigned int* size) {
   if (h == nullptr || raw == nullptr || size == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
@@ -543,19 +517,19 @@ RPC_API int rpc_port_parcel_get_raw(rpc_port_parcel_h h, void** raw,
 }
 
 RPC_API int rpc_port_parcel_create_from_raw(rpc_port_parcel_h* h,
-    const void* raw, unsigned int size) {
+                                            const void* raw,
+                                            unsigned int size) {
   if (h == nullptr || raw == nullptr || size == 0)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   rpc_port_parcel_h parcel;
   int ret = rpc_port_parcel_create(&parcel);
-  if (ret != RPC_PORT_ERROR_NONE)
-    return ret;
+  if (ret != RPC_PORT_ERROR_NONE) return ret;
 
   ret = rpc_port_parcel_from_array(parcel, raw, size);
   if (ret != RPC_PORT_ERROR_NONE) {
     rpc_port_parcel_destroy(parcel);  // LCOV_EXCL_LINE
-    return ret;  // LCOV_EXCL_LINE
+    return ret;                       // LCOV_EXCL_LINE
   }
 
   *h = parcel;
@@ -563,12 +537,10 @@ RPC_API int rpc_port_parcel_create_from_raw(rpc_port_parcel_h* h,
 }
 
 RPC_API int rpc_port_parcel_create_without_header(rpc_port_parcel_h* h) {
-  if (h == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (h == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   auto* parcel = new (std::nothrow) internal::Parcel(true);
-  if (parcel == nullptr)
-    return RPC_PORT_ERROR_OUT_OF_MEMORY;
+  if (parcel == nullptr) return RPC_PORT_ERROR_OUT_OF_MEMORY;
 
   *h = static_cast<rpc_port_parcel_h>(parcel);
   return RPC_PORT_ERROR_NONE;