Fix checking of return value from snprintf()