C
CptDondo
I'm working with some legacy C code. Apparently the author didn't know
or care about the difference between int, int16_t, unsigned int, and so
on. He does a lot of bitwise |, &, etc on signed int, without regard to
the size of int and sign flipping. The result is that the code produces
valid results most of the time, and garbage the rest of the time.
I've already lost a few days to auditing the code by hand. Is there
some way to audit the code for a) consistency between passed parameters,
to make sure that all passed parameters are of the same type, and b)
something to warn me if I am doing bitwise |, &, >>, etc on signed ints?
or care about the difference between int, int16_t, unsigned int, and so
on. He does a lot of bitwise |, &, etc on signed int, without regard to
the size of int and sign flipping. The result is that the code produces
valid results most of the time, and garbage the rest of the time.
I've already lost a few days to auditing the code by hand. Is there
some way to audit the code for a) consistency between passed parameters,
to make sure that all passed parameters are of the same type, and b)
something to warn me if I am doing bitwise |, &, >>, etc on signed ints?