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

Fix some logging formats #7921

Merged
merged 2 commits into from
Jun 28, 2021
Merged

Conversation

bzbarsky-apple
Copy link
Contributor

Problem

Compile error on some compiler; reported on Slack

Change overview

Use the right format.

Testing

Compiled locally, but the real test will be whether the bug reporter can compile...

Trying to log them as 16-bit integers fails on some compilers, since
they are 8-bit.
@bluebin14
Copy link
Contributor

For reference the format errors (hundreds of them in generated code) were caused by two lines in zap template, e.g.

../../../../../src/controller/data_model/gen/IMClusterCommandHandler.cpp:127:83: error: format specifies type 'unsigned short' but the argument has type 'chip::CommandId' (aka 'unsigned char') [-Werror,-Wformat]
ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, aCommandId, ZCL_ACCOUNT_LOGIN_CLUSTER_ID);

../../../../../examples/chip-tool/commands/clusters/Commands.h:1213:99: error: format specifies type 'unsigned short' but the argument has type 'uint8_t' (aka 'unsigned char') [-Werror,-Wformat]
ChipLogProgress(chipTool, "Sending cluster (0x050E) command (0x00) on endpoint %" PRIu16, endpointId);

Confirming that the PR fixes the errors.

@bluebin14
Copy link
Contributor

You can reproduce the build failure with any version of llvm/clang, e.g. edit examples/chip-tool/BUILD.gn so it has the following cflags:

cflags = [
"-Wconversion",
"-Wformat-type-confusion",
]

Build will fail due to type confusion with the same errors as above. Adding -Wformat-type-confusion to global settings would catch future errors.

@bzbarsky-apple
Copy link
Contributor Author

Adding -Wformat-type-confusion to global settings would catch future errors.

Filed #7935 on this; need to find the right place to add this.

@woody-apple woody-apple merged commit 9c03faa into project-chip:master Jun 28, 2021
@bzbarsky-apple bzbarsky-apple deleted the fix-formats branch June 28, 2021 22:14
nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this pull request Sep 23, 2021
* Fix log formats for command and endpoint.

Trying to log them as 16-bit integers fails on some compilers, since
they are 8-bit.

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

Successfully merging this pull request may close these issues.

6 participants