]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
tests/qtest/bios-tables-test: Check for dup2() failure
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 25 May 2021 13:44:53 +0000 (14:44 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 3 Jun 2021 15:43:27 +0000 (16:43 +0100)
Coverity notes that we don't check for dup2() failing.  Add some
assertions so that if it does ever happen we get some indication.
(This is similar to how we handle other "don't expect this syscall to
fail" checks in this test code.)

Fixes: Coverity CID 1432346
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-id: 20210525134458.6675-2-peter.maydell@linaro.org

tests/qtest/bios-tables-test.c

index 156d4174aa360739f009774581c9d09256d0c69a..51d3a4e23903fe965a1cb38f46a43902f45e6789 100644 (file)
@@ -489,10 +489,14 @@ static void test_acpi_asl(test_data *data)
                                                  exp_sdt->asl_file, sdt->asl_file);
                     int out = dup(STDOUT_FILENO);
                     int ret G_GNUC_UNUSED;
+                    int dupret;
 
-                    dup2(STDERR_FILENO, STDOUT_FILENO);
+                    g_assert(out >= 0);
+                    dupret = dup2(STDERR_FILENO, STDOUT_FILENO);
+                    g_assert(dupret >= 0);
                     ret = system(diff) ;
-                    dup2(out, STDOUT_FILENO);
+                    dupret = dup2(out, STDOUT_FILENO);
+                    g_assert(dupret >= 0);
                     close(out);
                     g_free(diff);
                 }