The mg_vsnprintf takes a size_t count but len is an integer. The value of len should be greater than 0 from the previous statements so should be safe to cast to size_t.