[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/6] tests/qtest/hd-geo-test: Fix checks on mkstemp() return valu
From: |
Peter Maydell |
Subject: |
[PATCH 3/6] tests/qtest/hd-geo-test: Fix checks on mkstemp() return value |
Date: |
Tue, 25 May 2021 14:44:55 +0100 |
Coverity notices that the checks against mkstemp() failing in
create_qcow2_with_mbr() are wrong: mkstemp returns -1 on failure but
the check is just "g_assert(fd)". Fix to use "g_assert(fd >= 0)",
matching the correct check in create_test_img().
Fixes: Coverity CID 1432274
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
tests/qtest/hd-geo-test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c
index f7b7cfbc2d1..113126ae06c 100644
--- a/tests/qtest/hd-geo-test.c
+++ b/tests/qtest/hd-geo-test.c
@@ -464,7 +464,7 @@ static char *create_qcow2_with_mbr(MBRpartitions mbr,
uint64_t sectors)
}
fd = mkstemp(raw_path);
- g_assert(fd);
+ g_assert(fd >= 0);
close(fd);
fd = open(raw_path, O_WRONLY);
@@ -474,7 +474,7 @@ static char *create_qcow2_with_mbr(MBRpartitions mbr,
uint64_t sectors)
close(fd);
fd = mkstemp(qcow2_path);
- g_assert(fd);
+ g_assert(fd >= 0);
close(fd);
qemu_img_path = getenv("QTEST_QEMU_IMG");
--
2.20.1
- [PATCH 0/6] tests: Fix some minor Coverity issues, Peter Maydell, 2021/05/25
- [PATCH 1/6] tests/qtest/bios-tables-test: Check for dup2() failure, Peter Maydell, 2021/05/25
- [PATCH 2/6] tests/qtest/e1000e-test: Check qemu_recv() succeeded, Peter Maydell, 2021/05/25
- [PATCH 4/6] tests/qtest/pflash-cfi02-test: Avoid potential integer overflow, Peter Maydell, 2021/05/25
- [PATCH 3/6] tests/qtest/hd-geo-test: Fix checks on mkstemp() return value,
Peter Maydell <=
- [PATCH 5/6] tests/qtest/tpm-tests: Remove unnecessary NULL checks, Peter Maydell, 2021/05/25
- [PATCH 6/6] tests/unit/test-vmstate: Assert that dup() and mkstemp() succeed, Peter Maydell, 2021/05/25