Static analysis of AsciiSPrint() and DEBUG()

Jake Garver <jake@...>

Hi folks,

I'd like to perform static analysis of our AsciiSPrint() and DebugPrint() calls. Specifically, I'd like to verify the arguments match the format string. I'm wondering if anyone has any experience here they'd like to share, including the tools they use.

I have had some success using cppcheck and configuring it to treat AsciiSPrint() and DebugPrint() similar to a printf. This was productive, but since these functions are only printf-like, the results weren't perfect. For example, on a %g, cppcheck expected a "double" but found a "GUID *". Further, I was also hoping it could help with %a vs. %s and UINT16 * vs. UINT8 * arguments. cppcheck doesn't currently allow customization here, so the source would need to be modified for it to understand EDK2 format strings.

Before I fork cppcheck and start teaching it about EDK2-style format strings, does anyone have a solution that's working for them?

Jake Garver