Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update chip-tool zapt to align with src/app/zap-templates #5141

Merged
merged 1 commit into from
Mar 4, 2021
Merged

Update chip-tool zapt to align with src/app/zap-templates #5141

merged 1 commit into from
Mar 4, 2021

Conversation

yufengwangca
Copy link
Contributor

@yufengwangca yufengwangca commented Mar 3, 2021

Problem

Once I run
./scripts/tools/zap_regen_all.py && ./gn_build.sh

Got the following error:
I../../third_party/lwip/repo/lwip/src/include -I../../src/lwip/include -I../../src/setup_payload -I../../third_party/inipp/repo/inipp -c ../../examples/chip-tool/main.cpp -o standalone/obj/examples/chip-tool/chip-tool.main.cpp.o
In file included from ../../examples/chip-tool/main.cpp:21:
../../examples/chip-tool/commands/clusters/Commands.h:4682:264: error: too many arguments to function call, expected 6, have 8
return cluster.SetFabric(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), reinterpret_cast<uint8_t*>(mFabricId), static_cast<uint32_t>(strlen(mFabricId)), reinterpret_cast<uint8_t*>(mFabricSecret), static_cast<uint32_t>(strlen(mFabricSecret)), mBreadcrumb, mTimeoutMs);
~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
../../src/controller/CHIPClusters.h:338:5: note: 'SetFabric' declared here
CHIP_ERROR SetFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, char * fabricId, char * fabricSecret, uint64_t breadcrumb, uint32_t timeoutMs);

The problem is chip-tool zapt translates type "byteString" to following two arguments:
"reinterpret_cast<uint8_t*>(arg), static_cast<uint32_t>(strlen(arg))"

This is not aligned with src/app/zap-templates, if we can take arg length with strlen, then it seems the length argument is not necessary.

Summary of Changes

Update chip-tool zapt to align with src/app/zap-templates

Test

./scripts/tools/zap_regen_all.py && ./gn_build.sh
All builds passed

@CLAassistant
Copy link

CLAassistant commented Mar 4, 2021

CLA assistant check
All committers have signed the CLA.

@@ -117,7 +125,7 @@ public:

chip::Controller::{{asCamelCased parent.name false}}Cluster cluster;
cluster.Associate(device, endpointId);
return cluster.{{asCamelCased name false}}(onSuccessCallback->Cancel(), onFailureCallback->Cancel(){{#chip_server_cluster_command_arguments}}, {{#if (isByteString type)}} reinterpret_cast<uint8_t*>(m{{asCamelCased label false}}), static_cast<uint32_t>(strlen(m{{asCamelCased label false}})){{else}}m{{asCamelCased label false}}{{/if}}{{/chip_server_cluster_command_arguments}});
return cluster.{{asCamelCased name false}}(onSuccessCallback->Cancel(), onFailureCallback->Cancel(){{#chip_server_cluster_command_arguments}}, {{#if (isByteString type)}} reinterpret_cast<char*>(m{{asCamelCased label false}}){{else}}m{{asCamelCased label false}}{{/if}}{{/chip_server_cluster_command_arguments}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bytes seem to be more correctly represented as uint8_t than char .

Should we not update the other way and enter a bug that 'using strlen for byte strings is not ok'?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The byte string bit is going to get fixed in #5122 to some extent, right? Though I guess #5122 (comment) is precisely about needing to change the member here to ByteSpan too.

And the rest of this looks like the PR I asked for in #5122 (comment) which I obviously approve of. ;)

@woody-apple
Copy link
Contributor

@vivien-apple ?

@@ -117,7 +125,7 @@ public:

chip::Controller::{{asCamelCased parent.name false}}Cluster cluster;
cluster.Associate(device, endpointId);
return cluster.{{asCamelCased name false}}(onSuccessCallback->Cancel(), onFailureCallback->Cancel(){{#chip_server_cluster_command_arguments}}, {{#if (isByteString type)}} reinterpret_cast<uint8_t*>(m{{asCamelCased label false}}), static_cast<uint32_t>(strlen(m{{asCamelCased label false}})){{else}}m{{asCamelCased label false}}{{/if}}{{/chip_server_cluster_command_arguments}});
return cluster.{{asCamelCased name false}}(onSuccessCallback->Cancel(), onFailureCallback->Cancel(){{#chip_server_cluster_command_arguments}}, {{#if (isByteString type)}} reinterpret_cast<char*>(m{{asCamelCased label false}}){{else}}m{{asCamelCased label false}}{{/if}}{{/chip_server_cluster_command_arguments}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The byte string bit is going to get fixed in #5122 to some extent, right? Though I guess #5122 (comment) is precisely about needing to change the member here to ByteSpan too.

And the rest of this looks like the PR I asked for in #5122 (comment) which I obviously approve of. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants