Features

 

The CleanC tool is a plug-in for the Eclipse/CDT development environment for C and C++ applications. It extracts and visualizes the function call graph and allows for detection of fragments in sequential C code that are potentially hard to analyze by MPSoC design tools and would lead to suboptimal solutions.

The tools finds violations against good development practices that result in C code that can be analyzed more effectively by tools:

  1. Distinguish source files from header files. Header files are for declarations, source files can define and declare items.

  2. Use macros for constants and conditional exclusion. The preprocessor engine of C is too powerful for its own good. We restricts its usage (as much as possible) to so-called object macros, useful for writing platform independent code.

  3. Keep variables local. No usage of global variables.

  4. Make sure a pointer points to only one data set. Do not use pointers to point to different data sets throughout its lifetime (e.g. to different arrays or to other entries within an array).

  5. Do not use recursive function calls.

  6. Do not use functions with varargs.

  7. Use switch statements instead of function pointers. Function pointers, especially anonymous function pointers, make C code very hard to understand for tools and humans alike.

  8. Use the manifest loop pattern. A manifest loop is a loop with an iterator which is initialized with a manifest value (a constant or value computed from iterators of outer loops), where the iterator is incremented or decremented with the same manifest value in each iteration, and where the loop finishes when the iterator reaches a certain manifest value.

  9. Make the control flow regular. Do not use break statements in loops, continue statements, goto statements, multiple return statements (unless in all of the difference branches of the same conditional) or break statements in anything but the last statement of a case statement.

  10. Keep side-effects out of expressions. Do not use side-effects within other expressions (e.g. incrementing a value while passing it as argument).

  11. Use indexes instead of pointer arithmetic.

  12. Do not cast to / from a pointer. Use casts properly, and do not cast a pointer type to a non-pointer type or the inverse (with the exception of casting arrays to pointer types with equal base types).

  13. Cast the result of malloc() to the correct type.

  14. Use arithmetic operators to perform calculations. Use proper arithmetic operators instead of bit operators as much as possible.

  15. Avoid the dark corners of the C standard. The C99 standard does not actually define what should happen with modulo or division with negative numbers, or volatile.

  16. Respect the semantics of types: While C is statically typed, user-defined types (typedefs) are only tye-checked according to the types they denote.


See the screenshots page for some information on what the tools look like, and the installation instructions to see how to install the plug-in in your Eclipse environment.