Static Analysis Tools Features: Built-in Detection and Extendable Detection
Some endian issues can be found with a static analysis tools' built-in features. These may or may not be flagged as specific to endianness, but due to a side-effect of another issue: For example, in the MISRA standards there are numerous rules which pertain to issues using multi-byte storage across different datatypes. These are not specifically intended to enforce errors in endian processing but may indeed, as the general pattern they are detecting is common.
If the static analysis tool has extendable features there can be many more custom issues detected. Key requirements for developing extensions are:
- Define syntactical specifications identifying error case(s).
- Define syntactical specifications identifying passing case(s).
- For both 1 and 2, if possible, define any flow sensitive issues to consider.
For best practices on the above, the error case must always give some possible hint to the solution. And if the defect is identified with a path which can be traced with the static analysis tool, fewer false positives for the error case can be the result.
Developing custom static analysis tools to detect issues requires that two main questions be answered first:
- What is your strategy for coding:
- "Endian-neutral?" "Endian-protocols?" or a blend?
- "what are the violations?" "what are the correct cases?"
Once those questions are answered, in particular question 2), static analysis rules can be developed to detect issues and enforce correctness.