Instead of an else here, I'd just leave an unconditional 'return 0' at the end of the function.

That way it is easier to follow: essentially checking a sequence of possible error conditions that all bail out with -1, followed by the final 'everything ok' return 0. It is easier to extend if there are other error conditions as well.