Skip to content

Commit c1b4121

Browse files
conghuic23acrnsi
authored andcommitted
dm: virtio-i2c: minor fix
Change the condition of checking native adapter number. Change sprintf to snprintf. Tracked-On: #3437 Signed-off-by: Conghui Chen <conghui.chen@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
1 parent d28264f commit c1b4121

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

devicemodel/hw/pci/virtio/virtio_i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ native_adapter_create(int bus, uint16_t slave_addr[], int n_slave)
443443
return NULL;
444444
}
445445

446-
sprintf(native_path, "/dev/i2c-%d", bus);
446+
snprintf(native_path, sizeof(native_path), "/dev/i2c-%d", bus);
447447
fd = open(native_path, O_RDWR);
448448
if (fd < 0) {
449449
WPRINTF("virtio_i2c: failed to open %s\n", native_path);
@@ -645,7 +645,7 @@ virtio_i2c_parse(struct virtio_i2c *vi2c, char *optstr)
645645
}
646646
cp = t;
647647
}
648-
if (n_adapter > MAX_NATIVE_I2C_ADAPTER) {
648+
if (n_adapter >= MAX_NATIVE_I2C_ADAPTER) {
649649
WPRINTF("too many adapter, only support %d \n", MAX_NATIVE_I2C_ADAPTER);
650650
return -1;
651651
}

0 commit comments

Comments
 (0)