-
Notifications
You must be signed in to change notification settings - Fork 3k
Avoid non-trivial copy when initializing lorastack struct #11395
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
Avoid non-trivial copy when initializing lorastack struct #11395
Conversation
@hugueskamba, thank you for your changes. |
@@ -83,7 +83,7 @@ LoRaMac::LoRaMac() | |||
_prev_qos_level(LORAWAN_DEFAULT_QOS), | |||
_demod_ongoing(false) | |||
{ | |||
memset(&_params, 0, sizeof(_params)); | |||
_params = loramac_protocol_params(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can go one step better by simply putting _params()
in the member-initializer-list above.
And a lot of the _params.keys.xxxx = NULL
or other settings to 0/false below can also go.
Either or both of those may lead to a code size saving.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was actually no code size saving but it is neat.
https://github.com/ARMmbed/mbed-os/compare/d914234d18cb510914926687a7a39bcfc085e287..5d2f4528856ad5730ab1012984266a3ae52d6185
Then
d914234
to
5d2f452
Compare
Using memset generates a warning about the non-trivial operation. Use member-initializer-list instead to initialise the structs members.
5d2f452
to
a306ad7
Compare
CI started |
Because of 5.14.0-rc1 CI jobs, we aborted CI job here. We will restart once 5.14.0rc1 is ready. |
Test run: FAILEDSummary: 2 of 4 test jobs failed Failed test jobs:
|
CI restarted |
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
CI restarted |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Description
Using
memset
generates a warning about the non-trivial operation.Use initializer list instead to initialise the struct members.
Pull request type
Reviewers
@evedon @kjbracey-arm
Release Notes