In a C project (OpenVPN is the project in question, commit 4029971240b6274b9b30e76ff74c7f689d7d9750) we had a emulation of bool
typedef int bool;
#define false 0
#define true 1
and now switch to C99 bool
#include <stdbool.h>
But in the project there is somewhere a bad usage of the bool. I know that the std bool behaves different. E.g.
bool t;
t=2;
if ( t == true)
printf("True!\n");
else
printf("False!\n");
Will return True! with stdbool.h
and False! with the #define
emulation.
My question Is there a way to find these code parts that behave different with stdbool and the emulated bool? Perhaps some compiler flag I overlooked or a good llvm or gcc intermediate format that can be diffed?
It is nothing as simple as in the example above but must be something that not as easy to see. Definitively not a == true.
UPDATE: We found the issue (mbuf_set has an int member len). It kind of stupid but the question still remains how to catch these. I am surprised the integer overflow checks don't catch things like this:
static inline bool
mbuf_len (const struct mbuf_set *ms)
{
return ms->len;
}