-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[fix] emberAfCopyString should accept size_t size[TE4] #8241
[fix] emberAfCopyString should accept size_t size[TE4] #8241
Conversation
4f64c89
to
0ccdc0f
Compare
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 actually fixed the issue that lighting app will return empty string for some fields.
Because the buffersize we pass in to typeSensitiveMemCopy
overflows uint8_t
? But shouldn't the real fix then be in the casting in that function? Because passing a size larger than uint8_t
to emberAfCopyString
doesn't necessarily make sense as things stand, because the callee will never copy more than uint8_t
s-count of bytes.... Unless we just want to make that param size_t
or something like that in general?
In any case, if this affects app behavior in an observable way, it sounds like we should be able to add CI for it. Can the problem be reproduced with all-clusters-app, or just with lighing-app?
I have previously tried to add unit tests for ember and failed - at that time recursive includes (ember lib including gen files) prevented me from creating a library to build tests upon. |
Agreed. The current behavior is:
If we're going to retain that behavior, size_t makes more sense to me. Isn't the bigger problem the silent truncation though? Is that actually what we want? |
This is why it matters that this is observable in an end-to-end test with lighting-app. We have end-to-end tests that exercise the sort of thing exercised in #8241 (comment) running in CI, so should be able to test this, I would think. |
@vivien-apple has been looking into that a bit recently, I think... |
removing the "TE4 cherrypick" label, while waiting for CSG's validation that it's needed. |
0ccdc0f
to
16d2700
Compare
Yes, we should add more tests between different apps -- I would suggest a follow up. Changed uint16_t -> size_t for |
Size increase report for "nrfconnect-example-build" from 0e19e0d
Full report output
|
Size increase report for "esp32-example-build" from 0e19e0d
Full report output
|
I respectfully disagree, unless the tests are a lot of work to add (which it doesn't seem like they should be if all-clusters-app shows the problem too). This is fixing an app-visible bug, we have an existing harness for exercising such things, it's easy to add tests to this harness, tests should be added with the fix if possible. Why would we not add the tests here? |
Ah, but it does not, because ATTRIBUTE_LARGEST there is not 257 like it is in lighting-app; it's 1001, which leads to different behavior inside emberAfCopyString. Alright, that's a good enough reason to sort out tests in a followup.... |
* [fix] emberAfCopyString should accept size_t size * Apply suggestions from code review Co-authored-by: Boris Zbarsky <[email protected]>
…8241) * [fix] emberAfCopyString should accept size_t size * Apply suggestions from code review Co-authored-by: Boris Zbarsky <[email protected]>
…8241) * [fix] emberAfCopyString should accept size_t size * Apply suggestions from code review Co-authored-by: Boris Zbarsky <[email protected]>
Problem
emberAfCopyString accepts uint8_t currently, however we should be able to pass longer buffer to emberAfCopyString.
Change overview
Testing
Manaully tested.
This actually fixed the issue that lighting app will return empty string for some fields.
Run lighting app with this PR: