@@ -150,8 +150,8 @@ std::vector<uint8_t> serialize_primitive_array(const sparrow::primitive_array<T>
150150
151151        //  arrow_arr.buffers[0] is the validity bitmap
152152        //  arrow_arr.buffers[1] is the data buffer
153-         const  uint8_t *  validity_bitmap = static_cast <const  uint8_t *>(arrow_arr.buffers [0 ]);
154-         const  uint8_t *  data_buffer = static_cast <const  uint8_t *>(arrow_arr.buffers [1 ]);
153+         const  auto  validity_bitmap = static_cast <const  uint8_t *>(arrow_arr.buffers [0 ]);
154+         const  auto  data_buffer = static_cast <const  uint8_t *>(arrow_arr.buffers [1 ]);
155155
156156        //  Calculate the size of the validity and data buffers
157157        int64_t  validity_size = (arrow_arr.length  + arrow_alignment - 1 ) / arrow_alignment;
@@ -183,10 +183,10 @@ std::vector<uint8_t> serialize_primitive_array(const sparrow::primitive_array<T>
183183        batch_builder.Finish (batch_message_offset);
184184
185185        //  III - Append the RecordBatch message to the final buffer
186-         uint32_t  batch_meta_len = batch_builder.GetSize (); //  Get the size of the batch metadata
187-         int64_t  aligned_batch_meta_len = align_to_8 (batch_meta_len); //  Calculate the padded length
186+         const   uint32_t  batch_meta_len = batch_builder.GetSize (); //  Get the size of the batch metadata
187+         const   int64_t  aligned_batch_meta_len = align_to_8 (batch_meta_len); //  Calculate the padded length
188188
189-         size_t  current_size = final_buffer.size (); //  Get the current size (which is the end of the Schema message)
189+         const   size_t  current_size = final_buffer.size (); //  Get the current size (which is the end of the Schema message)
190190        //  Resize the buffer to append the new message
191191        final_buffer.resize (current_size + sizeof (uint32_t ) + aligned_batch_meta_len + body_len);
192192        uint8_t * dst = final_buffer.data () + current_size; //  Get a pointer to where the new message will start
@@ -207,7 +207,8 @@ std::vector<uint8_t> serialize_primitive_array(const sparrow::primitive_array<T>
207207        else 
208208        {
209209            //  If validity_bitmap is null, it means there are no nulls
210-             memset (dst, 0xFF , validity_size);
210+             constexpr  uint8_t  no_nulls_bitmap = 0xFF ;
211+             memset (dst, no_nulls_bitmap, validity_size);
211212        }
212213        dst += validity_size;
213214        if  (data_buffer)
@@ -230,7 +231,7 @@ sparrow::primitive_array<T> deserialize_primitive_array(const std::vector<uint8_
230231    size_t  current_offset = 0 ;
231232
232233    //  I - Deserialize the Schema message
233-     uint32_t  schema_meta_len;
234+     uint32_t  schema_meta_len =  0 ;
234235    memcpy (&schema_meta_len, buf_ptr + current_offset, sizeof (schema_meta_len));
235236    current_offset += sizeof (uint32_t );
236237    auto  schema_message = org::apache::arrow::flatbuf::GetMessage (buf_ptr + current_offset);
@@ -248,7 +249,7 @@ sparrow::primitive_array<T> deserialize_primitive_array(const std::vector<uint8_
248249    current_offset += schema_meta_len;
249250
250251    //  II - Deserialize the RecordBatch message
251-     uint32_t  batch_meta_len;
252+     uint32_t  batch_meta_len =  0 ;
252253    memcpy (&batch_meta_len, buf_ptr + current_offset, sizeof (batch_meta_len));
253254    current_offset += sizeof (uint32_t );
254255    auto  batch_message = org::apache::arrow::flatbuf::GetMessage (buf_ptr + current_offset);
0 commit comments