Is there a tool like lint that can check potential endianness issue in a C code base? It's probably unrealistic for a tool to detect such problem during data sharing like network programming or file transfer. But checking that pointer casting abuse should not be that hard, right?
Basically, I'd like a tool to detect situation similar to the following code snippet.
#include <stdio.h>
void bar(char *cp)
{
*cp = 'c';
}
void foo(int *intp)
{
bar((char*)intp);
}
int main(void)
{
int a = 0xAABBCCDD;
foo(&a);
printf("a = %d\n", a);
return 0;
}
Any suggestion appreciated.