Fix the overwriting of errno before use in a DEBUG statement and use the return value...