Compile code using the highest warning level available for your compiler and eliminate warnings by modifying the code.
According to guideline C99 the C Standard, section 5.1.1.3 [ISO/IEC 9899:19992011], Section 5.1.1.3
A conforming implementation shall produce at least one diagnostic message (identified in an implementation-defined manner) if a preprocessing translation unit or translation unit contains a violation of any syntax rule or constraint, even if the behavior is also explicitly specified as undefined or implementation-defined. Diagnostic messages need not be produced in other circumstances.
Assuming a conforming implementation, eliminating diagnostic messages will eliminate any syntactic or constraint violations.
If suitable source code-checking code–checking tools are available, use them regularly.
...
MSC00-EX1: Compilers can produce diagnostic messages for correct code, as is permitted by C99 C [ISO/IEC 9899:19992011]. It is usually preferable to rewrite code to eliminate compiler warnings, but , if the code is correct, it is sufficient to provide a comment explaining why the warning message does not apply. Some compilers provide ways to suppress warnings, such as suitably formatted comments or pragmas, which can be used sparingly when the programmer understands the implications of the warning but has good reason to use the flagged construct anyway.
...
CERT C++ Secure Coding Standard: MSC00-CPP. Compile cleanly at high warning levels
ISO/IEC 9899:19992011Section 5.1.1.3, "Diagnostics"
MITRE CWE: CWE-563, "Unused Variablevariable"
MITRE CWE: CWE-570, "Expression is Always Falsealways false"
MITRE CWE: CWE-571, "Expression is Always Truealways true"
...
Sources
[Sutter 2005] Item 1
[Seacord 2005a] Chapter 8, "Recommended Practices"
...