These help avoiding overflows and simplify error handling. Signed-off-by: Martin Storsjö <martin@martin.st>