Skip to content

Commit d36b44f

Browse files
lifeixwenlingz
authored andcommitted
hv: avoid to use "++" or "--" operators in an expression
Use these operators in an expression is considered dangerous. So avoid to use it in an expression which is not in stand-alone expressions and the 3rd expression of a for loop. Tracked-On: #861 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent f33edc6 commit d36b44f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hypervisor/dm/vpci/sharing_mode.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ static struct pci_vdev *alloc_pci_vdev(struct acrn_vm *vm, union pci_bdf bdf)
106106
struct pci_vdev *vdev;
107107

108108
if (num_pci_vdev < CONFIG_MAX_PCI_DEV_NUM) {
109-
vdev = &sharing_mode_vdev_array[num_pci_vdev++];
109+
vdev = &sharing_mode_vdev_array[num_pci_vdev];
110+
num_pci_vdev++;
110111

111112
/* vbdf equals to pbdf otherwise remapped */
112113
vdev->vbdf = bdf;
@@ -186,7 +187,8 @@ void add_vdev_handler(struct pci_vdev *vdev, struct pci_vdev_ops *ops)
186187
if (vdev->nr_ops >= (MAX_VPCI_DEV_OPS - 1U)) {
187188
pr_err("%s, adding too many handlers", __func__);
188189
} else {
189-
vdev->ops[vdev->nr_ops++] = *ops;
190+
vdev->ops[vdev->nr_ops] = *ops;
191+
vdev->nr_ops++;
190192
}
191193
}
192194

0 commit comments

Comments
 (0)