Skip to contentSkip to conversation

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

PATCH In review Philippe Mathieu-Daudé 3 participants 3 messages Sep 2, 2020 – Sep 3, 2020

lore
Share & tools
lore
#0 lore raw

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

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)
---
 tests/qtest/ahci-test.c | 1 +
 1 file changed, 1 insertion(+)
tests/qtest/ahci-test.c +1 -0
index ca4294f44f3..5e1954852e7 100644
@@ -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);
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Philippe Mathieu-Daudé

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)
---
 tests/qtest/ahci-test.c | 1 +
 1 file changed, 1 insertion(+)
tests/qtest/ahci-test.c +0 -0
index ca4294f44f3..5e1954852e7 100644

tests/qtest/ahci-test.c static int prepare_iso(size_t size, unsigned char **buf, char **name) · line 1446

Quoted 4 lines
tests/qtest/ahci-test.c +1 -0
@@ -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.

#2 lore raw
In reply to Philippe Mathieu-Daudé
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

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/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]