Skip to content

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

Conversation

hugueskamba
Copy link
Collaborator

Description

Using memset generates a warning about the non-trivial operation.
Use initializer list instead to initialise the struct members.

Pull request type

[X] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@evedon @kjbracey-arm

Release Notes

@ciarmcom ciarmcom requested review from evedon, kjbracey and a team September 2, 2019 15:00
@ciarmcom
Copy link
Member

ciarmcom commented Sep 2, 2019

@hugueskamba, thank you for your changes.
@kjbracey-arm @evedon @ARMmbed/mbed-os-wan @ARMmbed/mbed-os-maintainers please review.

@@ -83,7 +83,7 @@ LoRaMac::LoRaMac()
_prev_qos_level(LORAWAN_DEFAULT_QOS),
_demod_ongoing(false)
{
memset(&_params, 0, sizeof(_params));
_params = loramac_protocol_params();
Copy link
Contributor

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.

Copy link
Collaborator Author

@hugueskamba hugueskamba Sep 3, 2019

Choose a reason for hiding this comment

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

@hugueskamba hugueskamba force-pushed the hk-replace-non-trivial-struct-initialization branch from d914234 to 5d2f452 Compare September 3, 2019 10:04
Using memset generates a warning about the non-trivial operation.
Use member-initializer-list instead to initialise the structs members.
@hugueskamba hugueskamba force-pushed the hk-replace-non-trivial-struct-initialization branch from 5d2f452 to a306ad7 Compare September 3, 2019 10:08
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 3, 2019

CI started

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 3, 2019

Because of 5.14.0-rc1 CI jobs, we aborted CI job here. We will restart once 5.14.0rc1 is ready.

@mbed-ci
Copy link

mbed-ci commented Sep 3, 2019

Test run: FAILED

Summary: 2 of 4 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-IAR
  • jenkins-ci/mbed-os-ci_build-GCC_ARM

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 4, 2019

CI restarted

@mbed-ci
Copy link

mbed-ci commented Sep 4, 2019

Test run: FAILED

Summary: 1 of 4 test jobs failed
Build number : 2
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-GCC_ARM

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 4, 2019

CI restarted

@mbed-ci
Copy link

mbed-ci commented Sep 4, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 3
Build artifacts

@0xc0170 0xc0170 merged commit 34a3948 into ARMmbed:master Sep 5, 2019
@hugueskamba hugueskamba deleted the hk-replace-non-trivial-struct-initialization branch September 10, 2019 07:54
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.

5 participants