[PATCH] tests/qtest/ahci: Improve error handling (NEGATIVE_RETURNS)

Philippe Mathieu-Daudé posted 1 patch 3 years, 8 months ago
Test docker-quick@centos7 failed
Test docker-mingw@fedora failed
Test checkpatch passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200902080552.159806-1-philmd@redhat.com
tests/qtest/ahci-test.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] tests/qtest/ahci: Improve error handling (NEGATIVE_RETURNS)
Posted by Philippe Mathieu-Daudé 3 years, 8 months ago
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);
     g_assert(buf);
     g_assert(name);
     patt = g_malloc(size);
-- 
2.26.2


Re: [PATCH] tests/qtest/ahci: Improve error handling (NEGATIVE_RETURNS)
Posted by Thomas Huth 3 years, 8 months ago
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>


Re: [PATCH] tests/qtest/ahci: Improve error handling (NEGATIVE_RETURNS)
Posted by no-reply@patchew.org 3 years, 8 months ago
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