I am looking for a software capable to refactor C code to make it more robust. In particular, tool must support detecting comparison against constants, such as numbers, macros or typedef enums.

For example: if (a == 'b') should be refactored to if ('b' == a)

Other cases:

typedef enum { ok, error } ab_t

if (func(x, y) == ok) //Refactor this...
if (ok == func(x, y)) //..to this

It would be also good to detect all unsigned types comparison against > 0, for example:

size_t i;
if (i > 0)
//should be
if (i)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.