Skip to content

Commit

Permalink
Add default initializers to cluster-objects structs.
Browse files Browse the repository at this point in the history
These were missed when adding initializers to other things, because
the structs' members are defined in a separate file now.
  • Loading branch information
bzbarsky-apple committed Jan 19, 2022
1 parent 4f84672 commit b97a4cd
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 154 deletions.
4 changes: 2 additions & 2 deletions src/app/zap-templates/partials/cluster-objects-struct.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace {{asUpperCamelCase name}} {
struct Type {
public:
{{#zcl_struct_items}}
{{zapTypeToEncodableClusterObjectType type}} {{asLowerCamelCase label}};
{{zapTypeToEncodableClusterObjectType type}} {{asLowerCamelCase label}}{{> cluster_objects_field_init}};
{{/zcl_struct_items}}

CHIP_ERROR Encode(TLV::TLVWriter &writer, TLV::Tag tag) const;
Expand All @@ -27,7 +27,7 @@ namespace {{asUpperCamelCase name}} {
struct DecodableType {
public:
{{#zcl_struct_items}}
{{zapTypeToDecodableClusterObjectType type}} {{asLowerCamelCase label}};
{{zapTypeToDecodableClusterObjectType type}} {{asLowerCamelCase label}}{{> cluster_objects_field_init}};
{{/zcl_struct_items}}
CHIP_ERROR Decode(TLV::TLVReader &reader);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,12 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw
ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type securityPolicy;
static_assert(sizeof(securityPolicy) == sizeof(activeDataset.mSecurityPolicy),
"securityPolicy Struct do not match otSecurityPolicy");
memcpy(&securityPolicy, &activeDataset.mSecurityPolicy, sizeof(securityPolicy));
uint16_t policyAsInts[2];
static_assert(sizeof(policyAsInts) == sizeof(activeDataset.mSecurityPolicy),
"We're missing some members of otSecurityPolicy?");
memcpy(&policyAsInts, &activeDataset.mSecurityPolicy, sizeof(policyAsInts));
securityPolicy.rotationTime = policyAsInts[0];
securityPolicy.flags = policyAsInts[1];

err = encoder.EncodeList([securityPolicy](const auto & aEncoder) -> CHIP_ERROR {
ReturnErrorOnFailure(aEncoder.Encode(securityPolicy));
Expand Down
Loading

0 comments on commit b97a4cd

Please sign in to comment.