-
-
Notifications
You must be signed in to change notification settings - Fork 549
Improve FunctionBar code regarding size handling #1720
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
|
The use of |
I can't get it. What I see is the value would never exceed To prevent further problems with structure alignment (what were addressed in #1702), I moved non-pointer members ( |
|
The other option, which I chose was to just fix the size of members so alignment gets resolved that way. Also, I prefer to have integer sizes fixed, unless the API requires otherwise … I think we can skip the additional shuffling of members and if you just keep the |
2cceb04 to
2ce0d3e
Compare
|
I've split the changes of this PR into two commits, so that the part without dispute can be applied (cherry-picked) first. And I'm still not convinced with keeping the |
a4c87b1 to
86c3216
Compare
|
Cherry-picked the structure reordering patch. |
The value of the 'FunctionBar.size' member is never meant to be greater than FUNCTIONBAR_MAXEVENTS (== 15) and so 'unsigned int' would suffice. No need to use a fixed 32-bit integer type. Signed-off-by: Kang-Che Sung <[email protected]>
86c3216 to
1fc3aff
Compare
|
If you argue regarding the size of the member and the actually used range, than even That said, there's little/no benefit of applying this remaining change of this PR IMO. |
My intention of using I'm not going to persuade any further, since with or without the patch, the compiled binary will be exactly the same and the source code difference is more of a style choice. |
FunctionBar.sizemember fromuint32_ttounsigned inttype because the value is never meant to be greater thanFUNCTIONBAR_MAXEVENTS(== 15).main)Add an assertion inFunctionBar_new()to indicate the fact above.main)Usesize_tfor loop iterators (array indices) in all FunctionBar methods. (This change will depend on compiler optimization to keep the same code size. In particular the recognition that a smaller iterator (32-bit) can be used when the limit is constrained to 32-bit integers.)