Skip to content

Commit a4b59cb

Browse files
authored
Bring PR #31776(Adjust storage for large payloads) from tcp branch to master (#33001)
* Adjust storage and processing in SystemPacketBuffer (#31776) and associated code for large payloads. Extend uint16_t type variables to size_t for the APIs and all applicable places. * Address review comments
1 parent a45386b commit a4b59cb

37 files changed

+316
-227
lines changed

src/app/BufferedReadCallback.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ CHIP_ERROR BufferedReadCallback::GenerateListTLV(TLV::ScopedBufferTLVReader & aR
6565
//
6666
// To avoid that, a single contiguous buffer is the best likely approach for now.
6767
//
68-
uint32_t totalBufSize = 0;
68+
size_t totalBufSize = 0;
6969
for (const auto & packetBuffer : mBufferedList)
7070
{
7171
totalBufSize += packetBuffer->TotalLength();

src/app/server/EchoHandler.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ chip::Protocols::Echo::EchoServer gEchoServer;
4040
*/
4141
void HandleEchoRequestReceived(chip::Messaging::ExchangeContext * ec, chip::System::PacketBufferHandle && payload)
4242
{
43-
ChipLogProgress(AppServer, "Echo Request, len=%u ... sending response.\n", payload->DataLength());
43+
ChipLogProgress(AppServer, "Echo Request, len=%" PRIu32 "... sending response.\n",
44+
static_cast<uint32_t>(payload->DataLength()));
4445
}
4546

4647
} // namespace

src/ble/BtpEngine.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <lib/support/BitFlags.h>
3535
#include <lib/support/BufferReader.h>
3636
#include <lib/support/CodeUtils.h>
37+
#include <lib/support/SafeInt.h>
3738
#include <lib/support/logging/CHIPLogging.h>
3839
#include <system/SystemPacketBuffer.h>
3940

@@ -282,7 +283,7 @@ CHIP_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle &&
282283
// mRxFragmentSize may be smaller than the characteristic size. Make sure
283284
// we're not truncating to a data length smaller than what we have already consumed.
284285
VerifyOrExit(reader.OctetsRead() <= mRxFragmentSize, err = BLE_ERROR_REASSEMBLER_INCORRECT_STATE);
285-
data->SetDataLength(chip::min(data->DataLength(), mRxFragmentSize));
286+
data->SetDataLength(chip::min(data->DataLength(), static_cast<size_t>(mRxFragmentSize)));
286287

287288
// Now mark the bytes we consumed as consumed.
288289
data->ConsumeHead(static_cast<uint16_t>(reader.OctetsRead()));
@@ -346,11 +347,12 @@ CHIP_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle &&
346347
if (rx_flags.Has(HeaderFlags::kEndMessage))
347348
{
348349
// Trim remainder, if any, of the received packet buffer based on sender-specified length of reassembled message.
349-
int padding = mRxBuf->DataLength() - mRxLength;
350+
VerifyOrExit(CanCastTo<uint16_t>(mRxBuf->DataLength()), err = CHIP_ERROR_MESSAGE_TOO_LONG);
351+
int padding = static_cast<uint16_t>(mRxBuf->DataLength()) - mRxLength;
350352

351353
if (padding > 0)
352354
{
353-
mRxBuf->SetDataLength(mRxLength);
355+
mRxBuf->SetDataLength(static_cast<size_t>(mRxLength));
354356
}
355357

356358
// Ensure all received fragments add up to sender-specified total message size.
@@ -375,7 +377,7 @@ CHIP_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle &&
375377
}
376378
if (!mRxBuf.IsNull())
377379
{
378-
ChipLogError(Ble, "With rx buf data length = %u", mRxBuf->DataLength());
380+
ChipLogError(Ble, "With rx buf data length = %u", static_cast<unsigned>(mRxBuf->DataLength()));
379381
}
380382
LogState();
381383

@@ -426,9 +428,10 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s
426428
return false;
427429
}
428430

429-
mTxBuf = std::move(data);
430-
mTxState = kState_InProgress;
431-
mTxLength = mTxBuf->DataLength();
431+
mTxBuf = std::move(data);
432+
mTxState = kState_InProgress;
433+
VerifyOrReturnError(CanCastTo<uint16_t>(mTxBuf->DataLength()), false);
434+
mTxLength = static_cast<uint16_t>(mTxBuf->DataLength());
432435

433436
ChipLogDebugBtpEngine(Ble, ">>> CHIPoBle preparing to send whole message:");
434437
PrintBufDebug(mTxBuf);

src/ble/tests/TestBtpEngine.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ TEST_F(TestBtpEngine, HandleCharacteristicReceivedOnePacket)
6767
};
6868

6969
auto packet0 = System::PacketBufferHandle::NewWithData(packetData0, sizeof(packetData0));
70-
EXPECT_EQ(packet0->DataLength(), 5);
70+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(5));
7171

7272
SequenceNumber_t receivedAck;
7373
bool didReceiveAck;
@@ -81,15 +81,15 @@ TEST_F(TestBtpEngine, HandleCharacteristicReceivedTwoPacket)
8181
constexpr uint8_t packetData1[] = { to_underlying(BtpEngine::HeaderFlags::kEndMessage), 0x02, 0xff };
8282

8383
auto packet0 = System::PacketBufferHandle::NewWithData(packetData0, sizeof(packetData0));
84-
EXPECT_EQ(packet0->DataLength(), 5);
84+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(5));
8585

8686
SequenceNumber_t receivedAck;
8787
bool didReceiveAck;
8888
EXPECT_EQ(mBtpEngine.HandleCharacteristicReceived(std::move(packet0), receivedAck, didReceiveAck), CHIP_NO_ERROR);
8989
EXPECT_EQ(mBtpEngine.RxState(), BtpEngine::kState_InProgress);
9090

9191
auto packet1 = System::PacketBufferHandle::NewWithData(packetData1, sizeof(packetData1));
92-
EXPECT_EQ(packet1->DataLength(), 3);
92+
EXPECT_EQ(packet1->DataLength(), static_cast<size_t>(3));
9393

9494
EXPECT_EQ(mBtpEngine.HandleCharacteristicReceived(std::move(packet1), receivedAck, didReceiveAck), CHIP_NO_ERROR);
9595
EXPECT_EQ(mBtpEngine.RxState(), BtpEngine::kState_Complete);
@@ -102,21 +102,21 @@ TEST_F(TestBtpEngine, HandleCharacteristicReceivedThreePacket)
102102
constexpr uint8_t packetData2[] = { to_underlying(BtpEngine::HeaderFlags::kEndMessage), 0x03, 0xff };
103103

104104
auto packet0 = System::PacketBufferHandle::NewWithData(packetData0, sizeof(packetData0));
105-
EXPECT_EQ(packet0->DataLength(), 5);
105+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(5));
106106

107107
SequenceNumber_t receivedAck;
108108
bool didReceiveAck;
109109
EXPECT_EQ(mBtpEngine.HandleCharacteristicReceived(std::move(packet0), receivedAck, didReceiveAck), CHIP_NO_ERROR);
110110
EXPECT_EQ(mBtpEngine.RxState(), BtpEngine::kState_InProgress);
111111

112112
auto packet1 = System::PacketBufferHandle::NewWithData(packetData1, sizeof(packetData1));
113-
EXPECT_EQ(packet1->DataLength(), 3);
113+
EXPECT_EQ(packet1->DataLength(), static_cast<size_t>(3));
114114

115115
EXPECT_EQ(mBtpEngine.HandleCharacteristicReceived(std::move(packet1), receivedAck, didReceiveAck), CHIP_NO_ERROR);
116116
EXPECT_EQ(mBtpEngine.RxState(), BtpEngine::kState_InProgress);
117117

118118
auto packet2 = System::PacketBufferHandle::NewWithData(packetData2, sizeof(packetData2));
119-
EXPECT_EQ(packet2->DataLength(), 3);
119+
EXPECT_EQ(packet2->DataLength(), static_cast<size_t>(3));
120120

121121
EXPECT_EQ(mBtpEngine.HandleCharacteristicReceived(std::move(packet2), receivedAck, didReceiveAck), CHIP_NO_ERROR);
122122
EXPECT_EQ(mBtpEngine.RxState(), BtpEngine::kState_Complete);
@@ -133,7 +133,7 @@ TEST_F(TestBtpEngine, HandleCharacteristicSendOnePacket)
133133

134134
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(packet0.Retain(), false));
135135
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_Complete);
136-
EXPECT_EQ(packet0->DataLength(), 5);
136+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(5));
137137
}
138138

139139
TEST_F(TestBtpEngine, HandleCharacteristicSendTwoPacket)
@@ -147,11 +147,11 @@ TEST_F(TestBtpEngine, HandleCharacteristicSendTwoPacket)
147147

148148
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(packet0.Retain(), false));
149149
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_InProgress);
150-
EXPECT_EQ(packet0->DataLength(), 20);
150+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(20));
151151

152152
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(nullptr, false));
153153
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_Complete);
154-
EXPECT_EQ(packet0->DataLength(), 16);
154+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(16));
155155
}
156156

157157
// Send 40-byte payload.
@@ -169,15 +169,15 @@ TEST_F(TestBtpEngine, HandleCharacteristicSendThreePacket)
169169

170170
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(packet0.Retain(), false));
171171
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_InProgress);
172-
EXPECT_EQ(packet0->DataLength(), 20);
172+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(20));
173173

174174
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(nullptr, false));
175175
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_InProgress);
176-
EXPECT_EQ(packet0->DataLength(), 20);
176+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(20));
177177

178178
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(nullptr, false));
179179
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_Complete);
180-
EXPECT_EQ(packet0->DataLength(), 8);
180+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(8));
181181
}
182182

183183
} // namespace

src/inet/TCPEndPoint.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ CHIP_ERROR TCPEndPoint::SetReceivedDataForTesting(System::PacketBufferHandle &&
126126
return CHIP_NO_ERROR;
127127
}
128128

129-
uint32_t TCPEndPoint::PendingSendLength()
129+
size_t TCPEndPoint::PendingSendLength()
130130
{
131131
if (!mSendQueue.IsNull())
132132
{
@@ -135,7 +135,7 @@ uint32_t TCPEndPoint::PendingSendLength()
135135
return 0;
136136
}
137137

138-
uint32_t TCPEndPoint::PendingReceiveLength()
138+
size_t TCPEndPoint::PendingReceiveLength()
139139
{
140140
if (!mRcvQueue.IsNull())
141141
{
@@ -333,8 +333,8 @@ void TCPEndPoint::DriveReceiving()
333333
{
334334
// Acknowledgement is done after handling the buffers to allow the
335335
// application processing to throttle flow.
336-
uint16_t ackLength = mRcvQueue->TotalLength();
337-
CHIP_ERROR err = OnDataReceived(this, std::move(mRcvQueue));
336+
size_t ackLength = mRcvQueue->TotalLength();
337+
CHIP_ERROR err = OnDataReceived(this, std::move(mRcvQueue));
338338
if (err != CHIP_NO_ERROR)
339339
{
340340
DoClose(err, false);

src/inet/TCPEndPoint.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class DLL_EXPORT TCPEndPoint : public EndPointBasis<TCPEndPoint>
274274
* received. The operational semantics are undefined if \c len is larger
275275
* than the total outstanding unacknowledged received data.
276276
*/
277-
virtual CHIP_ERROR AckReceive(uint16_t len) = 0;
277+
virtual CHIP_ERROR AckReceive(size_t len) = 0;
278278

279279
/**
280280
* @brief Set the receive queue, for testing.
@@ -295,15 +295,15 @@ class DLL_EXPORT TCPEndPoint : public EndPointBasis<TCPEndPoint>
295295
*
296296
* @return Number of untransmitted bytes in the transmit queue.
297297
*/
298-
uint32_t PendingSendLength();
298+
size_t PendingSendLength();
299299

300300
/**
301301
* @brief Extract the length of the unacknowledged receive data.
302302
*
303303
* @return Number of bytes in the receive queue that have not yet been
304304
* acknowledged with <tt>AckReceive(uint16_t len)</tt>.
305305
*/
306-
uint32_t PendingReceiveLength();
306+
size_t PendingReceiveLength();
307307

308308
/**
309309
* @brief Initiate TCP half close, in other words, finished with sending.
@@ -447,7 +447,7 @@ class DLL_EXPORT TCPEndPoint : public EndPointBasis<TCPEndPoint>
447447
* is the length of the message text added to the TCP transmit window,
448448
* which are eligible for sending by the underlying network stack.
449449
*/
450-
typedef void (*OnDataSentFunct)(TCPEndPoint * endPoint, uint16_t len);
450+
typedef void (*OnDataSentFunct)(TCPEndPoint * endPoint, size_t len);
451451

452452
/**
453453
* The endpoint's message text transmission event handling function

src/inet/TCPEndPointImplLwIP.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ CHIP_ERROR TCPEndPointImplLwIP::DriveSendingImpl()
350350
do
351351
{
352352
VerifyOrDie(!startOfUnsent.buffer.IsNull());
353-
354-
uint16_t bufDataLen = startOfUnsent.buffer->DataLength();
353+
VerifyOrDie(CanCastTo<uint16_t>(startOfUnsent.buffer->DataLength()));
354+
uint16_t bufDataLen = static_cast<uint16_t>(startOfUnsent.buffer->DataLength());
355355

356356
// Get a pointer to the start of unsent data within the first buffer on the unsent queue.
357357
const uint8_t * sendData = startOfUnsent.buffer->Start() + startOfUnsent.offset;
@@ -503,16 +503,18 @@ void TCPEndPointImplLwIP::DoCloseImpl(CHIP_ERROR err, State oldState)
503503
}
504504
}
505505

506-
CHIP_ERROR TCPEndPointImplLwIP::AckReceive(uint16_t len)
506+
CHIP_ERROR TCPEndPointImplLwIP::AckReceive(size_t len)
507507
{
508508
VerifyOrReturnError(IsConnected(), CHIP_ERROR_INCORRECT_STATE);
509509
CHIP_ERROR res = CHIP_NO_ERROR;
510510

511+
VerifyOrReturnError(CanCastTo<uint16_t>(len), CHIP_ERROR_INVALID_ARGUMENT);
512+
511513
// Lock LwIP stack
512514
LOCK_TCPIP_CORE();
513515

514516
if (mTCP != nullptr)
515-
tcp_recved(mTCP, len);
517+
tcp_recved(mTCP, static_cast<uint16_t>(len));
516518
else
517519
res = CHIP_ERROR_CONNECTION_ABORTED;
518520

@@ -570,7 +572,8 @@ TCPEndPointImplLwIP::BufferOffset TCPEndPointImplLwIP::FindStartOfUnsent()
570572
while (leftToSkip > 0)
571573
{
572574
VerifyOrDie(!startOfUnsent.buffer.IsNull());
573-
uint16_t bufDataLen = startOfUnsent.buffer->DataLength();
575+
VerifyOrDie(CanCastTo<uint16_t>(startOfUnsent.buffer->DataLength()));
576+
uint16_t bufDataLen = static_cast<uint16_t>(startOfUnsent.buffer->DataLength());
574577
if (leftToSkip >= bufDataLen)
575578
{
576579
// We have more to skip than current packet buffer size.

src/inet/TCPEndPointImplLwIP.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TCPEndPointImplLwIP : public TCPEndPoint, public EndPointStateLwIP
5151
CHIP_ERROR EnableNoDelay() override;
5252
CHIP_ERROR EnableKeepAlive(uint16_t interval, uint16_t timeoutCount) override;
5353
CHIP_ERROR DisableKeepAlive() override;
54-
CHIP_ERROR AckReceive(uint16_t len) override;
54+
CHIP_ERROR AckReceive(size_t len) override;
5555
#if INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
5656
void TCPUserTimeoutHandler() override;
5757
#endif // INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT

src/inet/TCPEndPointImplOpenThread.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ CHIP_ERROR TCPEndPointImplOT::DisableKeepAlive()
5454
{
5555
return CHIP_ERROR_NOT_IMPLEMENTED;
5656
}
57-
CHIP_ERROR TCPEndPointImplOT::AckReceive(uint16_t len)
57+
CHIP_ERROR TCPEndPointImplOT::AckReceive(size_t len)
5858
{
5959
return CHIP_ERROR_NOT_IMPLEMENTED;
6060
}

src/inet/TCPEndPointImplOpenThread.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class TCPEndPointImplOT : public TCPEndPoint, public EndPointStateOpenThread
4646
CHIP_ERROR EnableNoDelay() override;
4747
CHIP_ERROR EnableKeepAlive(uint16_t interval, uint16_t timeoutCount) override;
4848
CHIP_ERROR DisableKeepAlive() override;
49-
CHIP_ERROR AckReceive(uint16_t len) override;
49+
CHIP_ERROR AckReceive(size_t len) override;
5050
#if INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
5151
void TCPUserTimeoutHandler() override;
5252
#endif // INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT

src/inet/TCPEndPointImplSockets.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ CHIP_ERROR TCPEndPointImplSockets::DisableKeepAlive()
441441
return CHIP_NO_ERROR;
442442
}
443443

444-
CHIP_ERROR TCPEndPointImplSockets::AckReceive(uint16_t len)
444+
CHIP_ERROR TCPEndPointImplSockets::AckReceive(size_t len)
445445
{
446446
VerifyOrReturnError(IsConnected(), CHIP_ERROR_INCORRECT_STATE);
447447

@@ -483,7 +483,7 @@ CHIP_ERROR TCPEndPointImplSockets::DriveSendingImpl()
483483

484484
while (!mSendQueue.IsNull())
485485
{
486-
uint16_t bufLen = mSendQueue->DataLength();
486+
size_t bufLen = mSendQueue->DataLength();
487487

488488
ssize_t lenSentRaw = send(mSocket, mSendQueue->Start(), bufLen, sendFlags);
489489

@@ -496,14 +496,13 @@ CHIP_ERROR TCPEndPointImplSockets::DriveSendingImpl()
496496
break;
497497
}
498498

499-
if (lenSentRaw < 0 || lenSentRaw > bufLen)
499+
if (lenSentRaw < 0 || bufLen < static_cast<size_t>(lenSentRaw))
500500
{
501501
err = CHIP_ERROR_INCORRECT_STATE;
502502
break;
503503
}
504504

505-
// Cast is safe because bufLen is uint16_t.
506-
uint16_t lenSent = static_cast<uint16_t>(lenSentRaw);
505+
size_t lenSent = static_cast<size_t>(lenSentRaw);
507506

508507
// Mark the connection as being active.
509508
MarkActive();

src/inet/TCPEndPointImplSockets.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class TCPEndPointImplSockets : public TCPEndPoint, public EndPointStateSockets
4646
CHIP_ERROR EnableNoDelay() override;
4747
CHIP_ERROR EnableKeepAlive(uint16_t interval, uint16_t timeoutCount) override;
4848
CHIP_ERROR DisableKeepAlive() override;
49-
CHIP_ERROR AckReceive(uint16_t len) override;
49+
CHIP_ERROR AckReceive(size_t len) override;
5050
#if INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
5151
void TCPUserTimeoutHandler() override;
5252
#endif // INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
@@ -72,7 +72,7 @@ class TCPEndPointImplSockets : public TCPEndPoint, public EndPointStateSockets
7272

7373
#if INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
7474
/// This counts the number of bytes written on the TCP socket since thelast probe into the TCP outqueue was made.
75-
uint32_t mBytesWrittenSinceLastProbe;
75+
size_t mBytesWrittenSinceLastProbe;
7676

7777
/// This is the measured size(in bytes) of the kernel TCP send queue at the end of the last user timeout window.
7878
uint32_t mLastTCPKernelSendQueueLen;

src/inet/UDPEndPointImplLwIP.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ void UDPEndPointImplLwIP::LwIPReceiveUDPMessage(void * arg, struct udp_pcb * pcb
352352
if (buf->HasChainedBuffer())
353353
{
354354
// Have to allocate a new big-enough buffer and copy.
355-
uint16_t messageSize = buf->TotalLength();
355+
size_t messageSize = buf->TotalLength();
356356
System::PacketBufferHandle copy = System::PacketBufferHandle::New(messageSize, 0);
357357
if (copy.IsNull() || buf->Read(copy->Start(), messageSize) != CHIP_NO_ERROR)
358358
{

src/inet/UDPEndPointImplOpenThread.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ CHIP_ERROR UDPEndPointImplOT::SendMsgImpl(const IPPacketInfo * aPktInfo, System:
225225
otMessageInfo messageInfo;
226226

227227
// For now the entire message must fit within a single buffer.
228-
VerifyOrReturnError(!msg->HasChainedBuffer(), CHIP_ERROR_MESSAGE_TOO_LONG);
228+
VerifyOrReturnError(!msg->HasChainedBuffer() && msg->DataLength() <= UINT16_MAX, CHIP_ERROR_MESSAGE_TOO_LONG);
229229

230230
memset(&messageInfo, 0, sizeof(messageInfo));
231231

@@ -237,7 +237,7 @@ CHIP_ERROR UDPEndPointImplOT::SendMsgImpl(const IPPacketInfo * aPktInfo, System:
237237
message = otUdpNewMessage(mOTInstance, NULL);
238238
VerifyOrExit(message != NULL, error = OT_ERROR_NO_BUFS);
239239

240-
error = otMessageAppend(message, msg->Start(), msg->DataLength());
240+
error = otMessageAppend(message, msg->Start(), static_cast<uint16_t>(msg->DataLength()));
241241

242242
if (error == OT_ERROR_NONE)
243243
{

0 commit comments

Comments
 (0)