Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Compiling Themis with recent GCC and Clang versions produces new warnings. We are treating warnings as errors. Resolve the warnings to avoid build failues when we upgrade the compilers.
Commit summary
Suppress false positive warning
Recent versions of GCC are getting smarter, but here it has outsmarted itself. Drop the compiler a hint that a 'possible null pointer dereference' is in fact impossible in this case.
Do not "fix up" iterator ordering
Recent versions of GCC started printing a warning about those lines:
It says that we are "assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2". In fact, we do assume that.
Here we try to be "helpful" and correct a possible mistake of swapping begin and end iterators. However, after thinking about it, this mistake is unlikely to happen. Moreover, we really rely on the user to provide correct iterators:
If any of these assumptions is broken, you get undefined behavior (most likely resuling in a crash caused by segmentation fault). We cannot verify these assumptions by simply checking that one address is lower than the other. Debug builds of STL may check that, but that's as good as you can get it in C++.
So stop doing that (un)helpful fixup. Remove the check and do not swap iterators, removing the cause of the warning too.
Initialize structs with memset() manually
In C, it is perfectly legal to zero-initialize structures with
{0}
, like this:However, this is not (always) legal in C++. Certain versions of afl-clang are more C++-leaning and produce warnings about uninitialized fields even when compiling C code.
Well, okay, I don't want to fence this code with suppressions, so replace this initialization is explicit memset() calls.
Checklist