imc: return meaningful error codes instead of -1