On 25-03-21, 14:17, Jie Deng wrote:
i2c->adapter_num is set here, but used in vi2c_remove_adapters. when you goto out from while {...}, i2c->adapter_num is always 0, May be a bug ?
It certainly is, this should fix it:
diff --git a/tools/vhost-user-i2c/main.c b/tools/vhost-user-i2c/main.c index 071493cbd5c5..65d27ef04d42 100644 --- a/tools/vhost-user-i2c/main.c +++ b/tools/vhost-user-i2c/main.c @@ -202,7 +202,7 @@ static void vi2c_remove_adapters(VuI2c *i2c) VI2cAdapter *adapter; int32_t i;
- for (i = 0; i < i2c->adapter_num; i++) { + for (i = 0; i < MAX_I2C_ADAPTER; i++) { adapter = i2c->adapter[i]; if (!adapter) { break;