Third version of this series. I addressed Jef's comments and dropped both patches that dealt with the dc_buffer code as they did more damage than good. Maybe I'll do a new set of patches just for the buffer code if I feel bored later.
/D
[PATCH 01/12] Cleanup: correctly handle upper bound of array [PATCH 02/12] Cleanup: avoid memory leaks [PATCH 03/12] Cleanup: avoid memory leak [PATCH 04/12] Cleanup: avoid memory leak [PATCH 05/12] Cleanup: avoid memory leak [PATCH 06/12] Cleanup: ensure string is 0 terminated [PATCH 07/12] Cleanup: avoid undefined shift operation [PATCH 08/12] Cleanup: remove dead code and return the correct return [PATCH 09/12] Cleanup: check return value of ioctl() [PATCH 10/12] Cleanup: consistently check return value of iostream [PATCH 11/12] Cleanup: bail on error [PATCH 12/12] Cleanup: remove confusing NULL check