From 10087649aa134c22e022be724e26b97a169170e2 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Sat, 27 May 2023 13:12:41 -0400 Subject: [PATCH] Zap regen (#26911) * Zap regen * Undo undesired file change --- .../MTRAttributeTLVValueDecoder.mm | 45 ++++++++++++------- .../CHIP/zap-generated/MTRCallbackBridge.mm | 43 ++++++++++++------ .../zap-generated/MTRCommandPayloadsObjc.mm | 18 ++++---- .../zap-generated/MTREventTLVValueDecoder.mm | 18 +++++--- 4 files changed, 82 insertions(+), 42 deletions(-) diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index 5ca0aa2d5b0fb1..2a8bcb79d39e90 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -10092,9 +10092,12 @@ static id _Nullable DecodeAttributeValueForOperationalStateCluster( while (iter_1.Next()) { auto & entry_1 = iter_1.GetValue(); NSString * newElement_1; - newElement_1 = [[NSString alloc] initWithBytes:entry_1.data() - length:entry_1.size() - encoding:NSUTF8StringEncoding]; + newElement_1 = AsString(entry_1); + if (newElement_1 == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + *aError = err; + return nil; + } [array_1 addObject:newElement_1]; } CHIP_ERROR err = iter_1.GetStatus(); @@ -10153,9 +10156,12 @@ static id _Nullable DecodeAttributeValueForOperationalStateCluster( MTROperationalStateClusterOperationalStateStruct * newElement_0; newElement_0 = [MTROperationalStateClusterOperationalStateStruct new]; newElement_0.operationalStateID = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.operationalStateID)]; - newElement_0.operationalStateLabel = [[NSString alloc] initWithBytes:entry_0.operationalStateLabel.data() - length:entry_0.operationalStateLabel.size() - encoding:NSUTF8StringEncoding]; + newElement_0.operationalStateLabel = AsString(entry_0.operationalStateLabel); + if (newElement_0.operationalStateLabel == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + *aError = err; + return nil; + } [array_0 addObject:newElement_0]; } CHIP_ERROR err = iter_0.GetStatus(); @@ -10177,9 +10183,12 @@ static id _Nullable DecodeAttributeValueForOperationalStateCluster( MTROperationalStateClusterOperationalStateStruct * _Nonnull value; value = [MTROperationalStateClusterOperationalStateStruct new]; value.operationalStateID = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.operationalStateID)]; - value.operationalStateLabel = [[NSString alloc] initWithBytes:cppValue.operationalStateLabel.data() - length:cppValue.operationalStateLabel.size() - encoding:NSUTF8StringEncoding]; + value.operationalStateLabel = AsString(cppValue.operationalStateLabel); + if (value.operationalStateLabel == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + *aError = err; + return nil; + } return value; } case Attributes::OperationalError::Id: { @@ -10195,14 +10204,20 @@ static id _Nullable DecodeAttributeValueForOperationalStateCluster( if (cppValue.errorStateLabel.IsNull()) { value.errorStateLabel = nil; } else { - value.errorStateLabel = [[NSString alloc] initWithBytes:cppValue.errorStateLabel.Value().data() - length:cppValue.errorStateLabel.Value().size() - encoding:NSUTF8StringEncoding]; + value.errorStateLabel = AsString(cppValue.errorStateLabel.Value()); + if (value.errorStateLabel == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + *aError = err; + return nil; + } } if (cppValue.errorStateDetails.HasValue()) { - value.errorStateDetails = [[NSString alloc] initWithBytes:cppValue.errorStateDetails.Value().data() - length:cppValue.errorStateDetails.Value().size() - encoding:NSUTF8StringEncoding]; + value.errorStateDetails = AsString(cppValue.errorStateDetails.Value()); + if (value.errorStateDetails == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + *aError = err; + return nil; + } } else { value.errorStateDetails = nil; } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm index f19e6f96def92f..228f624bd14719 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm @@ -8941,7 +8941,12 @@ while (iter_1.Next()) { auto & entry_1 = iter_1.GetValue(); NSString * newElement_1; - newElement_1 = [[NSString alloc] initWithBytes:entry_1.data() length:entry_1.size() encoding:NSUTF8StringEncoding]; + newElement_1 = AsString(entry_1); + if (newElement_1 == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + OnFailureFn(context, err); + return; + } [array_1 addObject:newElement_1]; } CHIP_ERROR err = iter_1.GetStatus(); @@ -8983,9 +8988,12 @@ MTROperationalStateClusterOperationalStateStruct * newElement_0; newElement_0 = [MTROperationalStateClusterOperationalStateStruct new]; newElement_0.operationalStateID = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.operationalStateID)]; - newElement_0.operationalStateLabel = [[NSString alloc] initWithBytes:entry_0.operationalStateLabel.data() - length:entry_0.operationalStateLabel.size() - encoding:NSUTF8StringEncoding]; + newElement_0.operationalStateLabel = AsString(entry_0.operationalStateLabel); + if (newElement_0.operationalStateLabel == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + OnFailureFn(context, err); + return; + } [array_0 addObject:newElement_0]; } CHIP_ERROR err = iter_0.GetStatus(); @@ -9019,9 +9027,12 @@ MTROperationalStateClusterOperationalStateStruct * _Nonnull objCValue; objCValue = [MTROperationalStateClusterOperationalStateStruct new]; objCValue.operationalStateID = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.operationalStateID)]; - objCValue.operationalStateLabel = [[NSString alloc] initWithBytes:value.operationalStateLabel.data() - length:value.operationalStateLabel.size() - encoding:NSUTF8StringEncoding]; + objCValue.operationalStateLabel = AsString(value.operationalStateLabel); + if (objCValue.operationalStateLabel == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + OnFailureFn(context, err); + return; + } DispatchSuccess(context, objCValue); }; @@ -9049,14 +9060,20 @@ if (value.errorStateLabel.IsNull()) { objCValue.errorStateLabel = nil; } else { - objCValue.errorStateLabel = [[NSString alloc] initWithBytes:value.errorStateLabel.Value().data() - length:value.errorStateLabel.Value().size() - encoding:NSUTF8StringEncoding]; + objCValue.errorStateLabel = AsString(value.errorStateLabel.Value()); + if (objCValue.errorStateLabel == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + OnFailureFn(context, err); + return; + } } if (value.errorStateDetails.HasValue()) { - objCValue.errorStateDetails = [[NSString alloc] initWithBytes:value.errorStateDetails.Value().data() - length:value.errorStateDetails.Value().size() - encoding:NSUTF8StringEncoding]; + objCValue.errorStateDetails = AsString(value.errorStateDetails.Value()); + if (objCValue.errorStateDetails == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + OnFailureFn(context, err); + return; + } } else { objCValue.errorStateDetails = nil; } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index 3d3d8ff2592c44..b3731db438dab9 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -6732,16 +6732,18 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct: if (decodableStruct.commandResponseState.errorStateLabel.IsNull()) { self.commandResponseState.errorStateLabel = nil; } else { - self.commandResponseState.errorStateLabel = - [[NSString alloc] initWithBytes:decodableStruct.commandResponseState.errorStateLabel.Value().data() - length:decodableStruct.commandResponseState.errorStateLabel.Value().size() - encoding:NSUTF8StringEncoding]; + self.commandResponseState.errorStateLabel = AsString(decodableStruct.commandResponseState.errorStateLabel.Value()); + if (self.commandResponseState.errorStateLabel == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + return err; + } } if (decodableStruct.commandResponseState.errorStateDetails.HasValue()) { - self.commandResponseState.errorStateDetails = - [[NSString alloc] initWithBytes:decodableStruct.commandResponseState.errorStateDetails.Value().data() - length:decodableStruct.commandResponseState.errorStateDetails.Value().size() - encoding:NSUTF8StringEncoding]; + self.commandResponseState.errorStateDetails = AsString(decodableStruct.commandResponseState.errorStateDetails.Value()); + if (self.commandResponseState.errorStateDetails == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + return err; + } } else { self.commandResponseState.errorStateDetails = nil; } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm index 23417d19afd3b7..6780e58cd97afd 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -1775,14 +1775,20 @@ static id _Nullable DecodeEventPayloadForOperationalStateCluster(EventId aEventI if (cppValue.errorState.errorStateLabel.IsNull()) { memberValue.errorStateLabel = nil; } else { - memberValue.errorStateLabel = [[NSString alloc] initWithBytes:cppValue.errorState.errorStateLabel.Value().data() - length:cppValue.errorState.errorStateLabel.Value().size() - encoding:NSUTF8StringEncoding]; + memberValue.errorStateLabel = AsString(cppValue.errorState.errorStateLabel.Value()); + if (memberValue.errorStateLabel == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + *aError = err; + return nil; + } } if (cppValue.errorState.errorStateDetails.HasValue()) { - memberValue.errorStateDetails = [[NSString alloc] initWithBytes:cppValue.errorState.errorStateDetails.Value().data() - length:cppValue.errorState.errorStateDetails.Value().size() - encoding:NSUTF8StringEncoding]; + memberValue.errorStateDetails = AsString(cppValue.errorState.errorStateDetails.Value()); + if (memberValue.errorStateDetails == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + *aError = err; + return nil; + } } else { memberValue.errorStateDetails = nil; }