aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristian Schoenebeck <qemu_oss@crudebyte.com>2020-10-30 13:07:03 +0100
committerChristian Schoenebeck <qemu_oss@crudebyte.com>2020-11-01 19:44:29 +0100
commit5409d8bea40289106e1005c41973382a7dfacf1c (patch)
tree040f0413663e22093437b4bc6aa6ba45e9def707 /tests
parent136b7af22774a6f0fb44c9c1b8c088b52e2e92ed (diff)
tests/9pfs: fix coverity error in create_local_test_dir()
Coverity wants the return value of mkdir() to be checked: /qemu/tests/qtest/libqos/virtio-9p.c: 48 in create_local_test_dir() 42 /* Creates the directory for the 9pfs 'local' filesystem driver to access. */ 43 static void create_local_test_dir(void) 44 { 45 struct stat st; 46 47 g_assert(local_test_path != NULL); >>> CID 1435963: Error handling issues (CHECKED_RETURN) >>> Calling "mkdir(local_test_path, 511U)" without checking return value. This library function may fail and return an error code. 48 mkdir(local_test_path, 0777); 49 50 /* ensure test directory exists now ... */ 51 g_assert(stat(local_test_path, &st) == 0); 52 /* ... and is actually a directory */ 53 g_assert((st.st_mode & S_IFMT) == S_IFDIR); So let's just do that and log an info-level message at least, because we actually only care if the required directory exists and we do have an existence check for that in place already. Reported-by: Coverity (CID 1435963) Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Reviewed-by: Greg Kurz <groug@kaod.org> Message-Id: <03f68c7ec08064e20f43797f4eb4305ad21e1e8e.1604061839.git.qemu_oss@crudebyte.com> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qtest/libqos/virtio-9p.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index 586e700b24..3671043108 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -47,11 +47,16 @@ static void init_local_test_path(void)
void virtio_9p_create_local_test_dir(void)
{
struct stat st;
+ int res;
init_local_test_path();
g_assert(local_test_path != NULL);
- mkdir(local_test_path, 0777);
+ res = mkdir(local_test_path, 0777);
+ if (res < 0) {
+ g_test_message("mkdir('%s') failed: %s", local_test_path,
+ strerror(errno));
+ }
/* ensure test directory exists now ... */
g_assert(stat(local_test_path, &st) == 0);