[Discuss] finding dead code in C projects

Tom Metro tmetro+blu at gmail.com
Mon Jun 17 20:55:43 EDT 2013


Greg Rundlett wrote:
> I'm wondering if anyone has success stories about finding dead code in
> large (C) projects?

I don't deal with C/C++ enough to have specific tools to recommend, but
the general principle should be something like:

1. develop comprehensive unit tests;
2. execute unit tests in a profiler;

The reports generated by the profiler will then point to the source that
never gets used. Then a developer can then do a bit of manual
investigation to confirm that it looks like that code path will never be
executed or if it is a deficiency in your unit tests. (You'll probably
also turn up a pile of previously unknown bugs in the code as a byproduct.)

Regardless of what tool you use to identify "dead" code, you'll want
unit tests to give you confidence to hack out the stuff you think is not
useful while not breaking anything that matters.

 -Tom

-- 
Tom Metro
Venture Logic, Newton, MA, USA
"Enterprise solutions through open source."
Professional Profile: http://tmetro.venturelogic.com/



More information about the Discuss mailing list