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

Use enum class for TLVElementType and TLVTagControl. #3157

Merged
merged 9 commits into from
Oct 12, 2020

Conversation

bzbarsky-apple
Copy link
Contributor

This makes it easy to give them as specific size spec, which will
prevent issues with people adding out-of-range values and simplify
-Wconversion work.

Problem

TLVElementType and TLVTagControl are raw enums, not enum classes, so proving that casts to 8-bit ints are safe is not trivial.

Summary of Changes

Make them 8-bit-backed enum classes, so the compiler will enforce things for us.

@@ -105,41 +105,41 @@
/*
* @brief Specifies an anonymous TLV element, which doesn't have any tag
*/
#define CHIP_TLV_TAG_ANONYMOUS chip::TLV::kTLVTagControl_Anonymous
#define CHIP_TLV_TAG_ANONYMOUS chip::TLV::TLVTagControl::Anonymous
Copy link
Contributor

Choose a reason for hiding this comment

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

this departs from C++ towards Haskell :-)

@@ -58,6 +58,16 @@ class PacketBuffer;
namespace chip {
namespace TLV {

inline uint8_t operator|(TLVElementType lhs, TLVTagControl rhs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nit: but strongly prefer white space around operator the operation | to improve readability.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we make .clang-format do that? if not, we're gonna have trouble enforcing

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. I can't seem to find anything in the clang-format documentation that indicates control over this specific behavior.

bzbarsky-apple and others added 9 commits October 12, 2020 14:21
This makes it easy to give them as specific size spec, which will
prevent issues with people adding out-of-range values and simplify
-Wconversion work.
Some devices are configured to act as Thread router instead of
sleepy-end device. This PR removes these incorrect or verbose comments.
…ject-chip#3175)

* [nRF Connect] README updates on Docker for MacOS and NCS version

* Restyled by prettier-markdown

* Rephrase a sentence

Co-authored-by: Restyled.io <commits@restyled.io>
…ude server init callbacks. (project-chip#3180)

This allows the app to implement
emberAfPluginOnOffClusterServerPostInitCallback to sync up the data
model state with the state of the actual device when the data model
initializes.
* Add a lot of pragma once changes. Now scripted!

* update pragma once in setup payload

* More pragma once

* Pragma once within platform and more

* pragma once in the crypto layer

* pragma once in examples

* Fix by restyle-diff
@github-actions
Copy link

Size increase report for "esp32-example-build"

File Section File VM
chip-wifi-echo.elf .flash.text 16 16
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-wifi-echo.elf and ./pull_artifact/chip-wifi-echo.elf:

sections,vmsize,filesize
.debug_info,0,458
.debug_loc,0,323
.debug_line,0,215
.debug_ranges,0,144
.debug_abbrev,0,24
.flash.text,16,16
[Unmapped],0,4
.debug_str,0,-508


@github-actions
Copy link

Size increase report for "nrfconnect-example-build"

File Section File VM
chip-lock.elf text 22 22
chip-lock.elf [LOAD #1 [RWX]] -6 -6
chip-lighting.elf text 22 22
chip-lighting.elf [LOAD #1 [RWX]] -6 -6
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-lock.elf and ./pull_artifact/chip-lock.elf:

sections,vmsize,filesize
.debug_info,0,539
.debug_loc,0,256
.debug_ranges,0,168
.debug_line,0,128
.debug_abbrev,0,24
text,22,22
.debug_frame,0,4
[Unmapped],0,-3
[LOAD #1 [RWX]],-6,-6
.debug_str,0,-508

Comparing ./master_artifact/chip-lighting.elf and ./pull_artifact/chip-lighting.elf:

sections,vmsize,filesize
.debug_info,0,539
.debug_loc,0,256
.debug_ranges,0,168
.debug_line,0,128
.debug_abbrev,0,24
text,22,22
[Unmapped],0,5
.debug_frame,0,4
[LOAD #1 [RWX]],-6,-6
.debug_str,0,-508

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize


@rwalker-apple rwalker-apple merged commit aa1f11c into project-chip:master Oct 12, 2020
@bzbarsky-apple bzbarsky-apple deleted the enum-class-tlv-tags branch June 16, 2021 14:33
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.

10 participants