Skip to content

Commit

Permalink
Fix and test heap allocation of PacketBuffers (#4632)
Browse files Browse the repository at this point in the history
* Fix and test heap allocation of PacketBuffers

#### Problem

CHIP has to option to use heap-allocated packet buffers
(with `CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE == 0`) but
this configuration has been neglected, and CHIP neither builds
nor runs in this configuration.

#### Summary of Changes

Build fixes:

- Default `CHIP_CONFIG_RMP_RETRANS_TABLE_SIZE` to 15 for heap case.
    15 is the default packet buffer pool size in SystemConfig.h.
    See also issue #4335 - Our definition of the CRMP retransmission
    table size does not really make sense

Runtime fixes:

- Ensure echo server has enough buffer space for the response (and added
  `CHECK_RETURN_VALUE` to `EnsureReservedSize()`).
- Added room for MAC in echo requester.
- Added room for MAC in `chipSendUnicast()`.
- Added parameters to `CloneData()` to request header and trailing
  space.
- Fixed CHIPMem initialization for some tests.
- Fix tests that didn't allocate enough space.

Build and code changes to assist memory troubleshooting (these should have
no cost unless enabled):

- Added a build flag `chip_config_memory_debug_checks` and corresponding
  preprocessor definition `CHIP_CONFIG_MEMORY_DEBUG_CHECKS` to enable extra
  memory checks, at a performance cost. In particular, new functions
  `Platform::MemoryDebugCheckPointer()` and `PacketBufferHandle::Check()`
  operate when this is enabled.
- Added a build flag `chip_config_memory_debug_dmalloc` and corresponding
  preprocessor definition `CHIP_CONFIG_MEMORY_DEBUG_DMALLOC` to use the
  dmalloc debugging malloc library.
- Clarified conditions for the four configurations of PacketBuffer allocation.
- Replaced some PacketBuffer #define constants with scoped constexprs.
- Renamed `CHIP_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC` to
  `CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE` to remove the ambiguity of
  what a ‘maximum allocation’ is.

Build and automated test changes:

- Made standalone builds default to heap allocation.
- Run a set of unit tests with dmalloc.

fixes #4395 - Heap packet buffer allocation is broken
fixes #4390 - ReliableMessageProtocol assumes a buffer pool

* review

* review 2

* fix messaging shutdown

* review 3

* fix tests

Co-authored-by: Justin Wood <[email protected]>
  • Loading branch information
kpschoedel and woody-apple authored Feb 10, 2021
1 parent 819c1e9 commit 1b6a96b
Show file tree
Hide file tree
Showing 43 changed files with 627 additions and 345 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020 Project CHIP Authors
# Copyright (c) 2020-2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Setup Build
run: |
case $BUILD_TYPE in
"main") GN_ARGS='';;
"main") GN_ARGS='chip_config_memory_debug_checks=true chip_config_memory_debug_dmalloc=true';;
"clang") GN_ARGS='is_clang=true';;
"mbedtls") GN_ARGS='chip_crypto="mbedtls"';;
*) ;;
Expand Down
4 changes: 2 additions & 2 deletions config/android/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2016-2017 Nest Labs, Inc.
* Copyright (c) 2019-2020 Google LLC.
* All rights reserved.
Expand Down Expand Up @@ -44,7 +44,7 @@

#define CHIP_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0

#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC 300
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 300

#define CHIP_CONFIG_ENABLE_FUNCT_ERROR_LOGGING 1

Expand Down
4 changes: 2 additions & 2 deletions config/ios/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2016-2017 Nest Labs, Inc.
* Copyright (c) 2019-2020 Google LLC.
* All rights reserved.
Expand Down Expand Up @@ -44,7 +44,7 @@

#define CHIP_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0

#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC 300
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 300

#define CHIP_CONFIG_ENABLE_FUNCT_ERROR_LOGGING 1

Expand Down
4 changes: 2 additions & 2 deletions config/standalone/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2016-2017 Nest Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -65,7 +65,7 @@

#define CHIP_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0

#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC 300
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0

#define CHIP_CONFIG_ENABLE_FUNCT_ERROR_LOGGING 1

Expand Down
7 changes: 7 additions & 0 deletions scripts/tests/gn_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ CHIP_ROOT="$(dirname "$0")/../.."

source "$CHIP_ROOT/scripts/activate.sh"

dmalloc=$(gn --root="$CHIP_ROOT" args "$CHIP_ROOT/out/$BUILD_TYPE" --short --list=chip_config_memory_debug_dmalloc)
if [ "x$dmalloc" == "xchip_config_memory_debug_dmalloc = true" ]; then
eval "$(dmalloc -b -l DMALLOC_LOG -i 1 high)"
export G_SLICE
G_SLICE=always-malloc # required for dmalloc compatibility
fi

env

set -x
Expand Down
7 changes: 4 additions & 3 deletions src/app/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CHIP_ERROR Command::Reset()
if (mCommandMessageBuf.IsNull())
{
// TODO: Calculate the packet buffer size
mCommandMessageBuf = System::PacketBufferHandle::New(System::kMaxPacketBufferSize);
mCommandMessageBuf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize);
VerifyOrExit(!mCommandMessageBuf.IsNull(), err = CHIP_ERROR_NO_MEMORY);
}

Expand Down Expand Up @@ -145,7 +145,7 @@ void Command::Shutdown()

chip::TLV::TLVWriter & Command::CreateCommandDataElementTLVWriter()
{
mCommandDataBuf = chip::System::PacketBufferHandle::New(System::kMaxPacketBufferSize);
mCommandDataBuf = chip::System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize);
if (mCommandDataBuf.IsNull())
{
ChipLogDetail(DataManagement, "Unable to allocate packet buffer");
Expand Down Expand Up @@ -275,7 +275,8 @@ CHIP_ERROR Command::FinalizeCommandsMessage()
err = mCommandMessageWriter.Finalize(&mCommandMessageBuf);
SuccessOrExit(err);

mCommandMessageBuf->EnsureReservedSize(CHIP_SYSTEM_CONFIG_HEADER_RESERVE_SIZE);
VerifyOrExit(mCommandMessageBuf->EnsureReservedSize(System::PacketBuffer::kDefaultHeaderReserve),
err = CHIP_ERROR_BUFFER_TOO_SMALL);

exit:
ChipLogFunctError(err);
Expand Down
61 changes: 41 additions & 20 deletions src/app/tests/TestMessageDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <app/MessageDef/ReadRequest.h>
#include <app/MessageDef/ReportData.h>
#include <core/CHIPTLVDebug.hpp>
#include <support/CHIPMem.h>
#include <support/UnitTestRegistration.h>
#include <system/TLVPacketBufferBackingStore.h>

Expand Down Expand Up @@ -748,7 +749,7 @@ void AttributePathTest(nlTestSuite * apSuite, void * apContext)
AttributePath::Builder attributePathBuilder;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
attributePathBuilder.Init(&writer);
BuildAttributePath(apSuite, attributePathBuilder);
chip::System::PacketBufferHandle buf;
Expand All @@ -771,7 +772,7 @@ void AttributePathListTest(nlTestSuite * apSuite, void * apContext)
chip::System::PacketBufferTLVReader reader;
AttributePathList::Builder attributePathListBuilder;

writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));

err = attributePathListBuilder.Init(&writer);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
Expand All @@ -796,7 +797,7 @@ void EventPathTest(nlTestSuite * apSuite, void * apContext)
EventPath::Builder eventPathBuilder;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
eventPathBuilder.Init(&writer);
BuildEventPath(apSuite, eventPathBuilder);
chip::System::PacketBufferHandle buf;
Expand All @@ -820,7 +821,7 @@ void EventPathListTest(nlTestSuite * apSuite, void * apContext)
chip::System::PacketBufferTLVReader reader;
EventPathList::Builder eventPathListBuilder;

writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));

err = eventPathListBuilder.Init(&writer);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
Expand All @@ -844,7 +845,7 @@ void CommandPathTest(nlTestSuite * apSuite, void * apContext)
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
CommandPath::Builder commandPathBuilder;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
err = commandPathBuilder.Init(&writer);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

Expand All @@ -870,7 +871,7 @@ void EventDataElementTest(nlTestSuite * apSuite, void * apContext)
EventDataElement::Parser eventDataElementParser;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
eventDataElementBuilder.Init(&writer);
BuildEventDataElement(apSuite, eventDataElementBuilder);
chip::System::PacketBufferHandle buf;
Expand All @@ -893,7 +894,7 @@ void EventListTest(nlTestSuite * apSuite, void * apContext)
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
EventList::Builder eventListBuilder;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
eventListBuilder.Init(&writer);
BuildEventList(apSuite, eventListBuilder);
chip::System::PacketBufferHandle buf;
Expand All @@ -915,7 +916,7 @@ void StatusElementTest(nlTestSuite * apSuite, void * apContext)
StatusElement::Parser statusElementParser;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
statusElementBuilder.Init(&writer);
BuildStatusElement(apSuite, statusElementBuilder);
chip::System::PacketBufferHandle buf;
Expand All @@ -939,7 +940,7 @@ void AttributeStatusElementTest(nlTestSuite * apSuite, void * apContext)
AttributeStatusElement::Parser attributeStatusElementParser;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
attributeStatusElementBuilder.Init(&writer);
BuildAttributeStatusElement(apSuite, attributeStatusElementBuilder);
chip::System::PacketBufferHandle buf;
Expand All @@ -961,7 +962,7 @@ void AttributeStatusListTest(nlTestSuite * apSuite, void * apContext)
CHIP_ERROR err = CHIP_NO_ERROR;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
AttributeStatusList::Builder attributeStatusListBuilder;
err = attributeStatusListBuilder.Init(&writer);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
Expand All @@ -985,7 +986,7 @@ void AttributeDataElementTest(nlTestSuite * apSuite, void * apContext)
AttributeDataElement::Parser attributeDataElementParser;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
attributeDataElementBuilder.Init(&writer);
BuildAttributeDataElement(apSuite, attributeDataElementBuilder);
chip::System::PacketBufferHandle buf;
Expand All @@ -1007,7 +1008,7 @@ void AttributeDataListTest(nlTestSuite * apSuite, void * apContext)
CHIP_ERROR err = CHIP_NO_ERROR;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
AttributeDataList::Builder attributeDataListBuilder;
attributeDataListBuilder.Init(&writer);
BuildAttributeDataList(apSuite, attributeDataListBuilder);
Expand All @@ -1028,7 +1029,7 @@ void AttributeDataVersionListTest(nlTestSuite * apSuite, void * apContext)
CHIP_ERROR err = CHIP_NO_ERROR;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
AttributeDataVersionList::Builder attributeDataVersionListBuilder;
attributeDataVersionListBuilder.Init(&writer);
BuildAttributeDataVersionList(apSuite, attributeDataVersionListBuilder);
Expand All @@ -1051,7 +1052,7 @@ void CommandDataElementTest(nlTestSuite * apSuite, void * apContext)
CommandDataElement::Parser commandDataElementParser;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
commandDataElementBuilder.Init(&writer);
BuildCommandDataElement(apSuite, commandDataElementBuilder);
chip::System::PacketBufferHandle buf;
Expand All @@ -1074,7 +1075,7 @@ void CommandListTest(nlTestSuite * apSuite, void * apContext)
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
CommandList::Builder commandListBuilder;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
commandListBuilder.Init(&writer);
BuildCommandList(apSuite, commandListBuilder);
chip::System::PacketBufferHandle buf;
Expand All @@ -1094,7 +1095,7 @@ void ReportDataTest(nlTestSuite * apSuite, void * apContext)
CHIP_ERROR err = CHIP_NO_ERROR;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
BuildReportData(apSuite, writer);
chip::System::PacketBufferHandle buf;
err = writer.Finalize(&buf);
Expand All @@ -1113,7 +1114,7 @@ void InvokeCommandTest(nlTestSuite * apSuite, void * apContext)
CHIP_ERROR err = CHIP_NO_ERROR;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
BuildInvokeCommand(apSuite, writer);
chip::System::PacketBufferHandle buf;
err = writer.Finalize(&buf);
Expand All @@ -1132,7 +1133,7 @@ void ReadRequestTest(nlTestSuite * apSuite, void * apContext)
CHIP_ERROR err = CHIP_NO_ERROR;
chip::System::PacketBufferTLVWriter writer;
chip::System::PacketBufferTLVReader reader;
writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize));
writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
BuildReadRequest(apSuite, writer);
chip::System::PacketBufferHandle buf;
err = writer.Finalize(&buf);
Expand Down Expand Up @@ -1176,15 +1177,35 @@ const nlTest sTests[] =
// clang-format on
} // namespace

/**
* Set up the test suite.
*/
static int TestSetup(void * inContext)
{
CHIP_ERROR error = chip::Platform::MemoryInit();
if (error != CHIP_NO_ERROR)
return FAILURE;
return SUCCESS;
}

/**
* Tear down the test suite.
*/
static int TestTeardown(void * inContext)
{
chip::Platform::MemoryShutdown();
return SUCCESS;
}

int TestMessageDef()
{
// clang-format off
nlTestSuite theSuite =
{
"MessageDef",
&sTests[0],
nullptr,
nullptr
TestSetup,
TestTeardown,
};
// clang-format on

Expand Down
3 changes: 2 additions & 1 deletion src/app/util/chip-message-send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
#include <assert.h>
#include <inet/InetLayer.h>
#include <support/logging/CHIPLogging.h>
#include <transport/SecureSessionMgr.h> // For SecureSessionMgr
#include <transport/SecureSessionMgr.h>
#include <transport/raw/MessageHeader.h>

using namespace chip;

Expand Down
2 changes: 1 addition & 1 deletion src/ble/BLEEndPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ BLE_ERROR BLEEndPoint::StartConnect()
mState = kState_Connecting;

// Build BLE transport protocol capabilities request.
buf = System::PacketBufferHandle::New(System::kMaxPacketBufferSize);
buf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize);
VerifyOrExit(!buf.IsNull(), err = BLE_ERROR_NO_MEMORY);

// Zero-initialize BLE transport capabilities request.
Expand Down
2 changes: 1 addition & 1 deletion src/ble/BtpEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ BLE_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle dat
data->ConsumeHead(startReader.OctetsRead());

// Create a new buffer for use as the Rx re-assembly area.
mRxBuf = System::PacketBufferHandle::New(System::kMaxPacketBufferSize);
mRxBuf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize);

VerifyOrExit(!mRxBuf.IsNull(), err = BLE_ERROR_NO_MEMORY);

Expand Down
2 changes: 1 addition & 1 deletion src/controller/CHIPDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ CHIP_ERROR Device::OpenPairingWindow(uint32_t timeout, bool useToken, uint16_t d
// Issue: https://github.com/project-chip/connectedhomeip/issues/4725

// Construct and send "open pairing window" message to the device
System::PacketBufferHandle buf = System::PacketBufferHandle::New(System::kMaxPacketBufferSize);
System::PacketBufferHandle buf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize);
System::PacketBufferTLVWriter writer;

writer.Init(std::move(buf));
Expand Down
4 changes: 2 additions & 2 deletions src/controller/java/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2016-2017 Nest Labs, Inc.
* Copyright (c) 2019-2020 Google LLC.
* All rights reserved.
Expand Down Expand Up @@ -43,7 +43,7 @@

#define CHIP_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0

#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC 300
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 300

#define CHIP_CONFIG_ENABLE_FUNCT_ERROR_LOGGING 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ CHIP_ERROR GenericNetworkProvisioningServerImpl<ImplClass>::HandleGetNetworks(ui
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD

// Allocate a buffer to hold the response.
respBuf = PacketBufferHandle::New(kMaxPacketBufferSize);
respBuf = PacketBufferHandle::New(PacketBuffer::kMaxSize);
VerifyOrExit(respBuf != NULL, err = CHIP_ERROR_NO_MEMORY);

// Encode the GetNetworks response data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ CHIP_ERROR GenericSoftwareUpdateManagerImpl<ImplClass>::PrepareQuery(void)
}

// Allocate a buffer to hold the image query.
mImageQueryPacketBuffer = PacketBufferHandle::New(kMaxPacketBufferSize);
mImageQueryPacketBuffer = PacketBufferHandle::New(PacketBuffer::kMaxSize);
VerifyOrExit(mImageQueryPacketBuffer != NULL, err = CHIP_ERROR_NO_MEMORY);

err = imageQuery.pack(mImageQueryPacketBuffer);
Expand Down
2 changes: 1 addition & 1 deletion src/inet/IPEndPointBasis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ void IPEndPointBasis::HandlePendingIO(uint16_t aPort)
lPacketInfo.Clear();
lPacketInfo.DestPort = aPort;

lBuffer = System::PacketBufferHandle::New(System::kMaxPacketBufferSizeWithoutReserve, 0);
lBuffer = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSizeWithoutReserve, 0);

if (!lBuffer.IsNull())
{
Expand Down
Loading

0 comments on commit 1b6a96b

Please sign in to comment.