|
| 1 | +From dce7020f3a9e542e6afbc59f131c77210df5f7db Mon Sep 17 00:00:00 2001 |
| 2 | +Message-ID: <dce7020f3a9e542e6afbc59f131c77210df5f7db.1714067071.git.stefan@agner.ch> |
| 3 | +From: Stefan Agner <stefan@agner.ch> |
| 4 | +Date: Thu, 25 Apr 2024 15:19:17 +0200 |
| 5 | +Subject: [PATCH] [Python] Fix OnRead[Event|Attribute]DataCallback for Arm64 |
| 6 | + Apple Patform devices |
| 7 | + |
| 8 | +On M1/Arm64 macOS systems, the OnReadEventDataCallback often returned |
| 9 | +an invalid status, e.g.: |
| 10 | +ValueError: 16 is not a valid Status |
| 11 | + |
| 12 | +Use size_t consistently to fix this issue. |
| 13 | +--- |
| 14 | + src/controller/python/chip/clusters/attribute.cpp | 8 ++++---- |
| 15 | + 1 file changed, 4 insertions(+), 4 deletions(-) |
| 16 | + |
| 17 | +diff --git a/src/controller/python/chip/clusters/attribute.cpp b/src/controller/python/chip/clusters/attribute.cpp |
| 18 | +index e31f3431b8..b73b4a49b4 100644 |
| 19 | +--- a/src/controller/python/chip/clusters/attribute.cpp |
| 20 | ++++ b/src/controller/python/chip/clusters/attribute.cpp |
| 21 | +@@ -71,10 +71,10 @@ struct __attribute__((packed)) DataVersionFilter |
| 22 | + using OnReadAttributeDataCallback = void (*)(PyObject * appContext, chip::DataVersion version, chip::EndpointId endpointId, |
| 23 | + chip::ClusterId clusterId, chip::AttributeId attributeId, |
| 24 | + std::underlying_type_t<Protocols::InteractionModel::Status> imstatus, uint8_t * data, |
| 25 | +- uint32_t dataLen); |
| 26 | ++ size_t dataLen); |
| 27 | + using OnReadEventDataCallback = void (*)(PyObject * appContext, chip::EndpointId endpointId, chip::ClusterId clusterId, |
| 28 | + chip::EventId eventId, chip::EventNumber eventNumber, uint8_t priority, uint64_t timestamp, |
| 29 | +- uint8_t timestampType, uint8_t * data, uint32_t dataLen, |
| 30 | ++ uint8_t timestampType, uint8_t * data, size_t dataLen, |
| 31 | + std::underlying_type_t<Protocols::InteractionModel::Status> imstatus); |
| 32 | + using OnSubscriptionEstablishedCallback = void (*)(PyObject * appContext, SubscriptionId subscriptionId); |
| 33 | + using OnResubscriptionAttemptedCallback = void (*)(PyObject * appContext, PyChipError aTerminationCause, |
| 34 | +@@ -114,7 +114,7 @@ public: |
| 35 | + VerifyOrDie(!aPath.IsListItemOperation()); |
| 36 | + size_t bufferLen = (apData == nullptr ? 0 : apData->GetRemainingLength() + apData->GetLengthRead()); |
| 37 | + std::unique_ptr<uint8_t[]> buffer = std::unique_ptr<uint8_t[]>(apData == nullptr ? nullptr : new uint8_t[bufferLen]); |
| 38 | +- uint32_t size = 0; |
| 39 | ++ size_t size = 0; |
| 40 | + // When the apData is nullptr, means we did not receive a valid attribute data from server, status will be some error |
| 41 | + // status. |
| 42 | + if (apData != nullptr) |
| 43 | +@@ -166,7 +166,7 @@ public: |
| 44 | + void OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, const StatusIB * apStatus) override |
| 45 | + { |
| 46 | + uint8_t buffer[CHIP_CONFIG_DEFAULT_UDP_MTU_SIZE]; |
| 47 | +- uint32_t size = 0; |
| 48 | ++ size_t size = 0; |
| 49 | + CHIP_ERROR err = CHIP_NO_ERROR; |
| 50 | + // When the apData is nullptr, means we did not receive a valid event data from server, status will be some error |
| 51 | + // status. |
| 52 | +-- |
| 53 | +2.44.0 |
| 54 | + |
0 commit comments