GCC Code Coverage Report


Directory: ./
File: Fw/FilePacket/StartPacket.cpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 10 42 23.8%
Functions: 1 5 20.0%
Branches: 4 20 20.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title StartPacket.cpp
3 // \author bocchino
4 // \brief cpp file for FilePacket::StartPacket
5 //
6 // \copyright
7 // Copyright 2009-2016, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12
13 #include <Fw/FilePacket/FilePacket.hpp>
14 #include <Fw/Types/Assert.hpp>
15
16 namespace Fw {
17
18 void FilePacket::StartPacket ::initialize(const U32 fileSize,
19 const char* const sourcePath,
20 const char* const destinationPath) {
21 this->m_header.initialize(FilePacket::T_START, 0);
22 this->m_fileSize = fileSize;
23 this->m_sourcePath.initialize(sourcePath);
24 this->m_destinationPath.initialize(destinationPath);
25 }
26
27 U32 FilePacket::StartPacket ::bufferSize() const {
28 return static_cast<U32>(this->m_header.bufferSize() + sizeof(this->m_fileSize) + this->m_sourcePath.bufferSize() +
29 this->m_destinationPath.bufferSize());
30 }
31
32 SerializeStatus FilePacket::StartPacket ::toBuffer(Buffer& buffer) const {
33 SerialBuffer serialBuffer(buffer.getData(), buffer.getSize());
34 return this->toSerialBuffer(serialBuffer);
35 }
36
37 2 SerializeStatus FilePacket::StartPacket ::fromSerialBuffer(SerialBuffer& serialBuffer) {
38 2 FW_ASSERT(this->m_header.m_type == T_START);
39
40 {
41 2 const SerializeStatus status = serialBuffer.deserializeTo(this->m_fileSize);
42
43
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (status != FW_SERIALIZE_OK) {
44 return status;
45 }
46 }
47
48 {
49 2 const SerializeStatus status = this->m_sourcePath.fromSerialBuffer(serialBuffer);
50
51
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (status != FW_SERIALIZE_OK) {
52 return status;
53 }
54 }
55
56 {
57 2 const SerializeStatus status = this->m_destinationPath.fromSerialBuffer(serialBuffer);
58
59
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (status != FW_SERIALIZE_OK) {
60 return status;
61 }
62 }
63
64
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (serialBuffer.getDeserializeSizeLeft() != 0) {
65 return FW_DESERIALIZE_SIZE_MISMATCH;
66 }
67
68 2 return FW_SERIALIZE_OK;
69 }
70
71 SerializeStatus FilePacket::StartPacket ::toSerialBuffer(SerialBuffer& serialBuffer) const {
72 FW_ASSERT(this->m_header.m_type == T_START);
73
74 {
75 const SerializeStatus status = this->m_header.toSerialBuffer(serialBuffer);
76
77 if (status != FW_SERIALIZE_OK) {
78 return status;
79 }
80 }
81
82 {
83 const SerializeStatus status = serialBuffer.serializeFrom(this->m_fileSize);
84
85 if (status != FW_SERIALIZE_OK) {
86 return status;
87 }
88 }
89
90 {
91 const SerializeStatus status = this->m_sourcePath.toSerialBuffer(serialBuffer);
92
93 if (status != FW_SERIALIZE_OK) {
94 return status;
95 }
96 }
97
98 {
99 const SerializeStatus status = this->m_destinationPath.toSerialBuffer(serialBuffer);
100
101 if (status != FW_SERIALIZE_OK) {
102 return status;
103 }
104 }
105
106 return FW_SERIALIZE_OK;
107 }
108
109 } // namespace Fw
110