[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 45/45] tests/unit/test-vmstate: Assert that dup() and mkstemp() su
From: |
Peter Maydell |
Subject: |
[PULL 45/45] tests/unit/test-vmstate: Assert that dup() and mkstemp() succeed |
Date: |
Thu, 3 Jun 2021 16:59:04 +0100 |
Coverity complains that we don't check for failures from dup()
and mkstemp(); add asserts that these syscalls succeeded.
Fixes: Coverity CID 1432516, 1432574
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20210525134458.6675-7-peter.maydell@linaro.org
---
tests/unit/test-vmstate.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c
index a001879585e..4688c03ea72 100644
--- a/tests/unit/test-vmstate.c
+++ b/tests/unit/test-vmstate.c
@@ -40,10 +40,12 @@ static int temp_fd;
/* Duplicate temp_fd and seek to the beginning of the file */
static QEMUFile *open_test_file(bool write)
{
- int fd = dup(temp_fd);
+ int fd;
QIOChannel *ioc;
QEMUFile *f;
+ fd = dup(temp_fd);
+ g_assert(fd >= 0);
lseek(fd, 0, SEEK_SET);
if (write) {
g_assert_cmpint(ftruncate(fd, 0), ==, 0);
@@ -1486,6 +1488,7 @@ int main(int argc, char **argv)
g_autofree char *temp_file = g_strdup_printf("%s/vmst.test.XXXXXX",
g_get_tmp_dir());
temp_fd = mkstemp(temp_file);
+ g_assert(temp_fd >= 0);
module_call_init(MODULE_INIT_QOM);
--
2.20.1
- [PULL 37/45] hvf: Remove hvf-accel-ops.h, (continued)
- [PULL 37/45] hvf: Remove hvf-accel-ops.h, Peter Maydell, 2021/06/03
- [PULL 36/45] hvf: Make synchronize functions static, Peter Maydell, 2021/06/03
- [PULL 32/45] hvf: Make hvf_set_phys_mem() static, Peter Maydell, 2021/06/03
- [PULL 39/45] hvf: Simplify post reset/init/loadvm hooks, Peter Maydell, 2021/06/03
- [PULL 40/45] tests/qtest/bios-tables-test: Check for dup2() failure, Peter Maydell, 2021/06/03
- [PULL 44/45] tests/qtest/tpm-tests: Remove unnecessary NULL checks, Peter Maydell, 2021/06/03
- [PULL 41/45] tests/qtest/e1000e-test: Check qemu_recv() succeeded, Peter Maydell, 2021/06/03
- [PULL 38/45] hvf: Introduce hvf vcpu struct, Peter Maydell, 2021/06/03
- [PULL 42/45] tests/qtest/hd-geo-test: Fix checks on mkstemp() return value, Peter Maydell, 2021/06/03
- [PULL 43/45] tests/qtest/pflash-cfi02-test: Avoid potential integer overflow, Peter Maydell, 2021/06/03
- [PULL 45/45] tests/unit/test-vmstate: Assert that dup() and mkstemp() succeed,
Peter Maydell <=
- Re: [PULL 00/45] target-arm queue, no-reply, 2021/06/03
- Re: [PULL 00/45] target-arm queue, Peter Maydell, 2021/06/03