Return -1 on error.