summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell2021-05-25 15:44:58 +0200
committerPeter Maydell2021-06-03 17:43:27 +0200
commit1c861885894d840235954060050d240259f5340b (patch)
tree05ffaa4e20018c74d89d3a91eb3edbc66111e0c0 /tests
parenttests/qtest/tpm-tests: Remove unnecessary NULL checks (diff)
downloadqemu-1c861885894d840235954060050d240259f5340b.tar.gz
qemu-1c861885894d840235954060050d240259f5340b.tar.xz
qemu-1c861885894d840235954060050d240259f5340b.zip
tests/unit/test-vmstate: Assert that dup() and mkstemp() succeed
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
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test-vmstate.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c
index a001879585..4688c03ea7 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);