-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
Remove extraneous zero initializers to clean up Qurt compiler warnings #28634
Remove extraneous zero initializers to clean up Qurt compiler warnings #28634
Conversation
This is an external library, modifying it makes it hard to integrate newer versions - that's why these have not been fixed previously |
Shoot! I have 3 PR's with changes to the spm_srxl files. Unfortunately, it's a C file that was copied over and given the cpp extension. Then the C++ compiler gives warnings because it has C specific stuff in it. |
@andyp1per Take a look at PR28643: #28643 If that is a more reasonable way to deal with these compiler warnings then I can close this PR. |
I think we just need to wear that cost next time we update, more important to get rid of clang warnings I think |
@katzfey what is a bit surprising is this doesn't seem to save any flash space. I would have expected variables to move from DATA to BSS with a corresponding flash saving |
Alternate forumation, same as we use in LUA:
.... but the compiler warning is pointing out a bug, so I reckong we just accept this PR. If we lock the error in with a |
@andyp1per my preference is not to use the ifdefs, and just fix the code, I think the cost of updating these quite small files at some point in the future will be low, and clang is correct about the initialisers being wrong for these nested structures |
I'd like @andyp1per to have a chance to comment before merge |
@tridge My understanding is that the compiler sees that you are initializing with 0 and puts them in bss anyways so shouldn't change anything there. |
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.
This looks ok to me - what testing have you done?
I have only tested on my Qurt based drone so it isn't actually exercising any of the changed code. But, in theory, this doesn't actually change anything. |
In fact, the object file is identical after the change. |
Extraneous zero initializers for global / static variables were removed to get rid of the following Qurt compiler warnings:
../../libraries/AP_RCProtocol/spm_srxl.cpp:78:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
SrxlTelemetryData srxlTelemData = {0};
^
{}
../../libraries/AP_RCProtocol/spm_srxl.cpp:83:34: warning: suggest braces around initialization of subobject [-Wmissing-braces]
static SrxlDevice srxlThisDev = {0};
^
{}
../../libraries/AP_RCProtocol/spm_srxl.cpp:91:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
static SrxlReceiverStats srxlRx = {0};
^
{}
../../libraries/AP_RCProtocol/spm_srxl.cpp:91:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
static SrxlReceiverStats srxlRx = {0};
^
{}
Since this data will end up in .bss and be zeroed out it does not need explicit zero initializers.