]> xenbits.xensource.com Git - libvirt.git/commitdiff
testNodeGetCellsFreeMemory: Fix off by one error
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 15 Sep 2016 15:42:36 +0000 (17:42 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 13 Oct 2016 01:26:41 +0000 (09:26 +0800)
Consider the following scenario:

  virsh # freecell --all
      0:       2048 KiB
      1:       4096 KiB
  --------------------
  Total:       6144 KiB

  virsh # freecell 0
  0: 2048 KiB

  virsh # freecell 1
  1: 4096 KiB

And now before this change:

  virsh # freecell 2

After this change:

  virsh # freecell 2
  error: invalid argument: Range exceeds available cells

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/test/test_driver.c

index dc1e5697c533681e871b0e83a2dd0b7aaa249fb5..51fb7c8f3fa997ecf0d705224ba9a4feb703dc4e 100644 (file)
@@ -2710,7 +2710,7 @@ static int testNodeGetCellsFreeMemory(virConnectPtr conn,
     int ret = -1;
 
     testDriverLock(privconn);
-    if (startCell > privconn->numCells) {
+    if (startCell >= privconn->numCells) {
         virReportError(VIR_ERR_INVALID_ARG,
                        "%s", _("Range exceeds available cells"));
         goto cleanup;