-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 a false positive warning of gcc 12+ -Werror=maybe-uninitialized #1209
Conversation
Instead of initializing the context to NULL, what about modifying the assertion: test_cond(c != NULL && c->err == REDIS_ERR_IO && strcmp(c->errstr, "Invalid timeout specified") == 0); Otherwise we still could dereference a NULL pointer. This should also be done for the subsequent assertion in the function. If you feel like making that change, I'll get this merged. |
Yep Venci (aka @eitlane) , indeed the above proposal is better, so please proceed. Note that you don't need to apply this patch in our own Amadeus package of hiredis, since now the other pull request about -Werror is merged, so I will apply my patch instead of this one in our package. |
@michael-grunder I tried that but it didn't remove the warning. I can see that something similar was done on line 217 in the same file
When I checked when this was made I found this PR (Fix compiler warnings) back in 2011.
Thanks, |
Feel free to keep your change that initializes the context to NULL. That said, the assertions should also be modified to ensure it is not NULL since |
That's reasonable. I did the update |
We merged a fix for a "maybe uninitialized" warning in #1209, but after merging there could actually have then been a double free. The reason is that when compiling with NDEBUG our assert macro becomes a no-op, meaning that execution would no longer stop after `assert(NULL)`. This commit just adds a simple panic macro which will execute regardless of whether NDEBUG is defined or not.
We merged a fix for a "maybe uninitialized" warning in #1209, but after merging there could actually have then been a double free. The reason is that when compiling with NDEBUG our assert macro becomes a no-op, meaning that execution would no longer stop after `assert(NULL)`. This commit just adds a simple panic macro which will execute regardless of whether NDEBUG is defined or not.
We merged a fix for a "maybe uninitialized" warning in #1209, but after merging there could actually have then been a double free. The reason is that when compiling with NDEBUG our assert macro becomes a no-op, meaning that execution would no longer stop after `assert(NULL)`. This commit just adds a simple panic macro which will execute regardless of whether NDEBUG is defined or not.
Hello,
The warning I have (which is treated as error) looks like this:
I reproduced it with gcc 12 and 13 (I didn't try on any previous versions)
Thanks,
V