tools/ffhash: read errno before calling functions which might change it