diff options
author | Tedd Ho-Jeong An <tedd.an@intel.com> | 2021-10-18 10:28:31 -0700 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2021-10-18 15:31:55 -0700 |
commit | 799f6ff793250bbc692964d000429549803528a1 (patch) | |
tree | 44317566c9334fd2f3ed4c1eb64e63ca96766162 /mesh/util.c | |
parent | cd75918d2176e8978e1808f3fe67151c4e974437 (diff) | |
download | bluez-799f6ff793250bbc692964d000429549803528a1.tar.gz |
mesh: Fix unchecked return value
This patch fixes the unchecked return value(CWE-252) issues reported by
the Coverity.
Diffstat (limited to 'mesh/util.c')
-rw-r--r-- | mesh/util.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/mesh/util.c b/mesh/util.c index 308e7d998..d505e7a0c 100644 --- a/mesh/util.c +++ b/mesh/util.c @@ -14,6 +14,7 @@ #define _GNU_SOURCE #include <dirent.h> +#include <errno.h> #include <ftw.h> #include <unistd.h> #include <stdio.h> @@ -117,12 +118,14 @@ int create_dir(const char *dir_name) } strncat(dir, prev + 1, next - prev); - mkdir(dir, 0755); + if (mkdir(dir, 0755) != 0) + l_error("Failed to create dir(%d): %s", errno, dir); prev = next; } - mkdir(dir_name, 0755); + if (mkdir(dir_name, 0755) != 0) + l_error("Failed to create dir(%d): %s", errno, dir_name); return 0; } @@ -138,7 +141,9 @@ static int del_fobject(const char *fpath, const struct stat *sb, int typeflag, case FTW_SL: default: - remove(fpath); + if (remove(fpath) < 0) + l_error("Failed to remove(%d): %s", errno, fpath); + l_debug("RM %s", fpath); break; } |