I'm having some difficulty to evaluate the revision of a software: the software was paid by customer years ago, never used, and now the customer have noticed that it doesn't work as expected.
Now this customer asked me to evaluate the project (I have the sources), and I should give an estimation of the time to fix it and probably a maintenance contract.
However, after having analysed the code all the day, I notice that the source code base is very bad. Here is the crucial characteristics:
- A lot of source lines (140K+)
- C++ without classes, all statically allocated, all externs, all public
- Poor comments, poor documentation
- A bunch of warnings, counted more than 7K+ times. Warnings spreads from unsigned/signed mismatch to aliased variables, till uninitialized variables.
- Static analysis tools have signaled buffer overflows, unassigned variables, suspect string operations.
- Lot of multithreading and no critical section at all.
The code will compile, but only the "debug" version is able to run for a short time. I suspect that buffer overflows are working enough.
I've already encountered code like this, I'm not surprised that it is not working as expected. Now I'm thinking how to face this task in the most convenient way, and this is what I thought:
- Fix all compiler warnings.
- Fix all static analysis warnings
- Ensure exclusive access to data shared across multiple threads
- Enable
_HAS_ITERATOR_DEBUGGING
for debuggingstd::vector
accesses (vector is used a lot). This imply an upgrade to VS 2005, at least. - Uses CRT heap debugging as much as possible, even if this imply to move most of the global variables to be allocated on the heap.
- Extensive use of assertions (along with minidump creationg for post-mortem analysis)
- Exhaustive test cases to prove/test software robustness.
I would like to prepare unit testing, but I should refactor methods with 2500+ lines, and it would add enough pain to give up.
I think I have a good plan, or maybe I'm only in the right direction. I think I'm missing a measurement to actually evaluate the work I could face. Any thoughts?