-
Notifications
You must be signed in to change notification settings - Fork 614
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 some compiler warnings #917
Conversation
I'd like an extra NORETURN defined specifically for func ptrs to avoid the attribute in regular code. NORETURN_PTR maybe? |
Sure, I'll add NORETURN_PTR. |
Branch rebased and updated. |
I've done as requested in @ensiform's review. Please could someone take another look at this? |
This looks good to me. Next reviewer can go ahead and merge. |
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.
Can you move the NORETURN
and NORETUTN_PTR
definitions to shared/qcommon/q_platform.h
? It would make more sense I think to move it there since it's platform/implementation dependent.
It issues compiler warnings (or did until recently), and git grep says nothing actually calls or mentions this function. Signed-off-by: Simon McVittie <smcv@debian.org>
clang can see that BufferRead() does not always assign to length, issuing this warning: IcarusImplementation.cpp|601 col 13| warning: ‘length’ may be used uninitialized in this function [-Wmaybe-uninitialized] (This only happens if the buffer is null, in which case we have bigger problems.) Signed-off-by: Simon McVittie <smcv@debian.org>
According to comments in code/game/g_public.h (whose version was already tagged noreturn), for function pointers this only works with the gcc/clang-specific spelling __attribute__((noreturn)), and not with the gcc/clang/MSVC abstraction NORETURN. For function implementations, we can use NORETURN to get MSVC support too. This lets the compiler reason about what returns and what doesn't, and in particular silences gcc warnings about functions that are declared NORETURN but that did appear to return. They didn't, because they ended with a call to (a function pointer that eventually calls) Com_Error, but without these annotations the compiler couldn't know that. Signed-off-by: Simon McVittie <smcv@debian.org>
Signed-off-by: Simon McVittie <smcv@debian.org>
This expands to the same thing as NORETURN on gcc (and clang), but expands to nothing on MSVC. Signed-off-by: Simon McVittie <smcv@debian.org>
Signed-off-by: Simon McVittie <smcv@debian.org>
@xycaleth: better now? I initially put For a lot of |
Much better :) |
Fix some compiler warnings (JACoders#917)
* Consistently declare Com_Error implementations as noreturn According to comments in code/game/g_public.h (whose version was already tagged noreturn), for function pointers this only works with the gcc/clang-specific spelling __attribute__((noreturn)), and not with the gcc/clang/MSVC abstraction NORETURN. For function implementations, we can use NORETURN to get MSVC support too. This lets the compiler reason about what returns and what doesn't, and in particular silences gcc warnings about functions that are declared NORETURN but that did appear to return. They didn't, because they ended with a call to (a function pointer that eventually calls) Com_Error, but without these annotations the compiler couldn't know that. Signed-off-by: Simon McVittie <smcv@debian.org> * AI_ClosestGroupEntityNumToPoint: Remove, unused It issues compiler warnings (or did until recently), and git grep says nothing actually calls or mentions this function. Signed-off-by: Simon McVittie <smcv@debian.org> * Icarus: Squash a compiler warning about possibly uninitialized length clang can see that BufferRead() does not always assign to length, issuing this warning: IcarusImplementation.cpp|601 col 13| warning: ‘length’ may be used uninitialized in this function [-Wmaybe-uninitialized] (This only happens if the buffer is null, in which case we have bigger problems.) Signed-off-by: Simon McVittie <smcv@debian.org> * Move definition of NORETURN to q_platform.h Signed-off-by: Simon McVittie <smcv@debian.org> * Introduce NORETURN_PTR, a version of NORETURN for function pointers This expands to the same thing as NORETURN on gcc (and clang), but expands to nothing on MSVC. Signed-off-by: Simon McVittie <smcv@debian.org> * Define NORETURN, NORETURN_PTR for non-gcc non-MSVC compilers Signed-off-by: Simon McVittie <smcv@debian.org>
* Consistently declare Com_Error implementations as noreturn According to comments in code/game/g_public.h (whose version was already tagged noreturn), for function pointers this only works with the gcc/clang-specific spelling __attribute__((noreturn)), and not with the gcc/clang/MSVC abstraction NORETURN. For function implementations, we can use NORETURN to get MSVC support too. This lets the compiler reason about what returns and what doesn't, and in particular silences gcc warnings about functions that are declared NORETURN but that did appear to return. They didn't, because they ended with a call to (a function pointer that eventually calls) Com_Error, but without these annotations the compiler couldn't know that. Signed-off-by: Simon McVittie <smcv@debian.org> * AI_ClosestGroupEntityNumToPoint: Remove, unused It issues compiler warnings (or did until recently), and git grep says nothing actually calls or mentions this function. Signed-off-by: Simon McVittie <smcv@debian.org> * Icarus: Squash a compiler warning about possibly uninitialized length clang can see that BufferRead() does not always assign to length, issuing this warning: IcarusImplementation.cpp|601 col 13| warning: ‘length’ may be used uninitialized in this function [-Wmaybe-uninitialized] (This only happens if the buffer is null, in which case we have bigger problems.) Signed-off-by: Simon McVittie <smcv@debian.org> * Move definition of NORETURN to q_platform.h Signed-off-by: Simon McVittie <smcv@debian.org> * Introduce NORETURN_PTR, a version of NORETURN for function pointers This expands to the same thing as NORETURN on gcc (and clang), but expands to nothing on MSVC. Signed-off-by: Simon McVittie <smcv@debian.org> * Define NORETURN, NORETURN_PTR for non-gcc non-MSVC compilers Signed-off-by: Simon McVittie <smcv@debian.org>
* Consistently declare Com_Error implementations as noreturn According to comments in code/game/g_public.h (whose version was already tagged noreturn), for function pointers this only works with the gcc/clang-specific spelling __attribute__((noreturn)), and not with the gcc/clang/MSVC abstraction NORETURN. For function implementations, we can use NORETURN to get MSVC support too. This lets the compiler reason about what returns and what doesn't, and in particular silences gcc warnings about functions that are declared NORETURN but that did appear to return. They didn't, because they ended with a call to (a function pointer that eventually calls) Com_Error, but without these annotations the compiler couldn't know that. Signed-off-by: Simon McVittie <smcv@debian.org> * AI_ClosestGroupEntityNumToPoint: Remove, unused It issues compiler warnings (or did until recently), and git grep says nothing actually calls or mentions this function. Signed-off-by: Simon McVittie <smcv@debian.org> * Icarus: Squash a compiler warning about possibly uninitialized length clang can see that BufferRead() does not always assign to length, issuing this warning: IcarusImplementation.cpp|601 col 13| warning: ‘length’ may be used uninitialized in this function [-Wmaybe-uninitialized] (This only happens if the buffer is null, in which case we have bigger problems.) Signed-off-by: Simon McVittie <smcv@debian.org> * Move definition of NORETURN to q_platform.h Signed-off-by: Simon McVittie <smcv@debian.org> * Introduce NORETURN_PTR, a version of NORETURN for function pointers This expands to the same thing as NORETURN on gcc (and clang), but expands to nothing on MSVC. Signed-off-by: Simon McVittie <smcv@debian.org> * Define NORETURN, NORETURN_PTR for non-gcc non-MSVC compilers Signed-off-by: Simon McVittie <smcv@debian.org>
Please see individual commits for details.
If any of the individual patches are not desired, the others can be cherry-picked.