[libvirt] [PATCH 2/4] testNodeGetCellsFreeMemory: Fix off by one error
Michal Privoznik
mprivozn at redhat.com
Wed Oct 5 07:30:57 UTC 2016
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 at redhat.com>
---
src/test/test_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 758327c..b760b4f 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -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;
--
2.8.4
More information about the libvir-list
mailing list