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. |
This avoids the null termination requirement of both String::substring and String::lastIndexOf by using APIs that don't require it. So we can stop writing to the buffer inside of const functions. I also changed wbuffer to make it non const.
Fixes #8462
This avoids the null termination requirement of both
String::substringandString::lastIndexOfby 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.