-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Avoid writing to const storage #8463
Conversation
Seems to have broken some host tests:
|
Arduino/tests/host/core/test_string.cpp Lines 417 to 420 in 30b0450
|
Will fix it, thanks! How can I run the host tests locally so I don't clutter the project's CI and can iterate over the code faster? |
In |
Hmm, I'm getting a bunch of compilation errors because of |
Were you intending to fix wbuffer() as well? It seems the const_cast originates b/c of the const qualifier(s), where the compiler did warn about the const misnomer but it was circumvented |
Yeah, I would prefer to make wbuffer into non const, should I change it in this PR too then? I will mess with this PR's code after work today. |
@d-a-v Done, your trick worked! I also changed wbuffer to make it non const. |
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.
LGTM
Fixes #8462
This avoids the null termination requirement of both
String::substring
andString::lastIndexOf
by using APIs that don't require it. So we can stop writing to the buffer inside of const functions.There might be a off by one error there, I need to take a better look at the code and would love if someone could review.