Resolving function pointers with static analysis
February 27, 2018
Function pointers in C are a useful construct, despite needing to look up the exact syntax when trying to program with them.
Function pointers in C are a useful construct, despite needing to look up the exact syntax when trying to program with them. They are potentially dangerous if misused since program execution can go to unwanted location. In fact, coding standards like MISRA C (e.g. rule 104) forbid the use of variable function pointers. If you are using function pointers, it can be tricky to figure out where they are pointing to. Luckily, a new function pointer resolver has been published to our customer community site for CodeSonar users.
The function pointer resolver makes use of our extension API to extend our existing set of rules. Once installed it can help identify which functions a pointer can point based on the abstract execution that CodeSonar performs during static analysis of the code. See the following screenshot.