From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: Greg Kurz <groug@kaod.org>
Subject: [PULL v2 02/16] tests/9pfs: fix coverity error in create_local_test_dir()
Date: Fri, 30 Oct 2020 13:07:03 +0100 [thread overview]
Message-ID: <de48a58b7714b50df0f1ed5ec1b64e06a72e17ee.1604067568.git.qemu_oss@crudebyte.com> (raw)
In-Reply-To: <cover.1604067568.git.qemu_oss@crudebyte.com>
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>
---
tests/qtest/libqos/virtio-9p.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index 6b22fa0e9a..8459a3ee58 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -48,9 +48,14 @@ static void init_local_test_path(void)
static void create_local_test_dir(void)
{
struct stat st;
+ int res;
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);
--
2.20.1
next prev parent reply other threads:[~2020-10-30 14:47 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 04/16] tests/9pfs: Factor out do_version() helper Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 07/16] tests/9pfs: Turn fs_readdir_split() into a helper Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 05/16] tests/9pfs: Set alloc in fs_create_dir() Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 06/16] tests/9pfs: Factor out do_attach() helper Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 08/16] tests/9pfs: Turn fs_mkdir() into a helper Christian Schoenebeck
2020-10-21 12:06 ` [PULL v2 09/16] tests/9pfs: simplify do_mkdir() Christian Schoenebeck
2020-10-21 12:17 ` [PULL v2 10/16] tests/9pfs: add local Tunlinkat directory test Christian Schoenebeck
2020-10-21 12:25 ` [PULL v2 11/16] tests/9pfs: add local Tlcreate test Christian Schoenebeck
2020-10-21 12:28 ` [PULL v2 12/16] tests/9pfs: add local Tunlinkat file test Christian Schoenebeck
2020-10-21 12:33 ` [PULL v2 13/16] tests/9pfs: add local Tsymlink test Christian Schoenebeck
2020-10-21 12:36 ` [PULL v2 14/16] tests/9pfs: add local Tunlinkat symlink test Christian Schoenebeck
2020-10-21 12:51 ` [PULL v2 15/16] tests/9pfs: add local Tlink test Christian Schoenebeck
2020-10-21 12:55 ` [PULL v2 16/16] tests/9pfs: add local Tunlinkat hard link test Christian Schoenebeck
2020-10-30 12:07 ` [PULL v2 01/16] tests/9pfs: fix test dir for parallel tests Christian Schoenebeck
2020-10-31 13:20 ` Christian Schoenebeck
2020-10-31 20:34 ` Peter Maydell
2020-10-31 21:15 ` Christian Schoenebeck
2020-11-01 11:37 ` Christian Schoenebeck
2020-10-30 12:07 ` Christian Schoenebeck [this message]
2020-10-30 12:46 ` [PULL v2 03/16] tests/9pfs: Force removing of local 9pfs test directory Christian Schoenebeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=de48a58b7714b50df0f1ed5ec1b64e06a72e17ee.1604067568.git.qemu_oss@crudebyte.com \
--to=qemu_oss@crudebyte.com \
--cc=groug@kaod.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).