Prepare for hbuf returning failure, replace some 'return -1' with gotos, clarify code.
Prepare for hbuf returning failure, replace some 'return -1' with gotos,
clarify code.

kristapsdz/lowdown,kristapsdz/lowdown,kristapsdz/lowdown