diff mbox series

tests/qtest/ahci: Improve error handling (NEGATIVE_RETURNS)

Message ID 20200902080552.159806-1-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series tests/qtest/ahci: Improve error handling (NEGATIVE_RETURNS) | expand

Commit Message

Philippe Mathieu-Daudé Sept. 2, 2020, 8:05 a.m. UTC
Fix an error handling issue reported by Coverity:

  /qemu/tests/qtest/ahci-test.c: 1452 in prepare_iso()
  1444         int fd = mkstemp(cdrom_path);
  >>>     CID 1432375:  Error handling issues  (NEGATIVE_RETURNS)
  >>>     "fd" is passed to a parameter that cannot be negative.
  1452         ret = write(fd, patt, size);

Reported-by: Coverity (CID 1432375)
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/ahci-test.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Thomas Huth Sept. 2, 2020, 9:36 a.m. UTC | #1
On 02/09/2020 10.05, Philippe Mathieu-Daudé wrote:
> Fix an error handling issue reported by Coverity:
> 
>   /qemu/tests/qtest/ahci-test.c: 1452 in prepare_iso()
>   1444         int fd = mkstemp(cdrom_path);
>   >>>     CID 1432375:  Error handling issues  (NEGATIVE_RETURNS)
>   >>>     "fd" is passed to a parameter that cannot be negative.
>   1452         ret = write(fd, patt, size);
> 
> Reported-by: Coverity (CID 1432375)
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  tests/qtest/ahci-test.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
> index ca4294f44f3..5e1954852e7 100644
> --- a/tests/qtest/ahci-test.c
> +++ b/tests/qtest/ahci-test.c
> @@ -1443,6 +1443,7 @@ static int prepare_iso(size_t size, unsigned char **buf, char **name)
>      ssize_t ret;
>      int fd = mkstemp(cdrom_path);
>  
> +    g_assert(fd != -1);

Should be good enough for a qtest.

Reviewed-by: Thomas Huth <thuth@redhat.com>
no-reply@patchew.org Sept. 3, 2020, 2:38 p.m. UTC | #2
Patchew URL: https://patchew.org/QEMU/20200902080552.159806-1-philmd@redhat.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

Clone of 'https://git.qemu.org/git/dtc.git' into submodule path 'dtc' failed
failed to update submodule dtc
Submodule 'dtc' (https://git.qemu.org/git/dtc.git) unregistered for path 'dtc'
make[1]: *** [/var/tmp/patchew-tester-tmp-rwu0f67e/src/docker-src.2020-09-03-10.37.46.30048] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-rwu0f67e/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    0m30.996s
user    0m2.113s


The full log is available at
http://patchew.org/logs/20200902080552.159806-1-philmd@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
diff mbox series

Patch

diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
index ca4294f44f3..5e1954852e7 100644
--- a/tests/qtest/ahci-test.c
+++ b/tests/qtest/ahci-test.c
@@ -1443,6 +1443,7 @@  static int prepare_iso(size_t size, unsigned char **buf, char **name)
     ssize_t ret;
     int fd = mkstemp(cdrom_path);
 
+    g_assert(fd != -1);
     g_assert(buf);
     g_assert(name);
     patt = g_malloc(size);