check the return value of snprintf