Use E_FAIL instead of -1 and clean up
Merge pull request #6951 from chinhodado/patch-5

Use E_FAIL instead of -1 and clean up