-
Notifications
You must be signed in to change notification settings - Fork 14
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
Cleaning Cppcheck warnings and refactor tests #115
Conversation
Pointersinstead of index_pI created a const and a non_const variable. If a new array is allocated, we use index_p and free the non_const variable. If we can use the initial variable, index_p is NULL and we don't use the non_const variable. String overflowIf a struct has a fixed-size string + some data, making an overflow in the string will corrupt data of the struct. So it is recommended to put strings at the end of structs, so that important data are less likely to be overwritten by s string overflow. |
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.
The string changes are very useful, thanks!
@q-posev ping! |
@scemama I responded a few days ago in this thread. I still believe that changes in this PR break the I/O of indices in 32-bit, which is why I am not ready to merge it. |
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.
@scemama Sorry, the review was marked as pending
for some reason by GitHub... You should be able to see it now
@scemama ping 🙂 |
@scemama thanks! I think the name of the PR can be changed to reflect that there was a major refactoring of the unit tests. I have one comment, let me know if you prefer to get it fixed in a separate PR or in this one: We discussed testing the |
Yes! It is better if I fix the tests in this PR also. I planned to do it, but I forgot... |
Done! |
Pointers
instead of
const char my_string[256] = "hello"
, we should useconst char* my_string = "hello"
index_p
I created a const and a non_const variable. If a new array is allocated, we use index_p and free the non_const variable. If we can use the initial variable, index_p is NULL and we don't use the non_const variable.
String overflow
If a struct has a fixed-size string + some data, making an overflow in the string will corrupt data of the struct. So it is recommended to put strings at the end of structs, so that important data are less likely to be overwritten by s string overflow.