src/util: Move assertion check out of function call