From d36b44f23dcb54544ea0132b202d7ec17453801b Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Thu, 6 Dec 2018 23:05:14 +0800 Subject: [PATCH] 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 --- hypervisor/dm/vpci/sharing_mode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hypervisor/dm/vpci/sharing_mode.c b/hypervisor/dm/vpci/sharing_mode.c index 640348d88..d4b90676f 100644 --- a/hypervisor/dm/vpci/sharing_mode.c +++ b/hypervisor/dm/vpci/sharing_mode.c @@ -106,7 +106,8 @@ static struct pci_vdev *alloc_pci_vdev(struct acrn_vm *vm, union pci_bdf bdf) struct pci_vdev *vdev; if (num_pci_vdev < CONFIG_MAX_PCI_DEV_NUM) { - vdev = &sharing_mode_vdev_array[num_pci_vdev++]; + vdev = &sharing_mode_vdev_array[num_pci_vdev]; + num_pci_vdev++; /* vbdf equals to pbdf otherwise remapped */ vdev->vbdf = bdf; @@ -186,7 +187,8 @@ void add_vdev_handler(struct pci_vdev *vdev, struct pci_vdev_ops *ops) if (vdev->nr_ops >= (MAX_VPCI_DEV_OPS - 1U)) { pr_err("%s, adding too many handlers", __func__); } else { - vdev->ops[vdev->nr_ops++] = *ops; + vdev->ops[vdev->nr_ops] = *ops; + vdev->nr_ops++; } }