diff options
author | Yunchih Chen <yunchih.cat@gmail.com> | 2019-04-04 21:16:56 +0800 |
---|---|---|
committer | Yunchih Chen <yunchih.cat@gmail.com> | 2019-04-07 22:36:00 +0800 |
commit | 87f3262b61616634677e57d25798f27c82fb5465 (patch) | |
tree | 0b79589c2e9e8281ae740f890a58cad871fd51a1 /lib/util.c | |
parent | ce362d2cc493debf6f52117cb88547c224ea84bc (diff) | |
download | nfcollect-87f3262b61616634677e57d25798f27c82fb5465.tar nfcollect-87f3262b61616634677e57d25798f27c82fb5465.tar.gz nfcollect-87f3262b61616634677e57d25798f27c82fb5465.tar.bz2 nfcollect-87f3262b61616634677e57d25798f27c82fb5465.tar.lz nfcollect-87f3262b61616634677e57d25798f27c82fb5465.tar.xz nfcollect-87f3262b61616634677e57d25798f27c82fb5465.tar.zst nfcollect-87f3262b61616634677e57d25798f27c82fb5465.zip |
Fix check_dir bug
Diffstat (limited to 'lib/util.c')
-rw-r--r-- | lib/util.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -17,13 +17,12 @@ int check_file_size(const char *storage) { int check_basedir_exist(const char *storage) { char *_storage = strdup(storage); char *basedir = dirname(_storage); - free(_storage); - struct stat d; - if (stat(basedir, &d) != 0 || !S_ISDIR(d.st_mode)) { - return -1; - } - return 0; + struct stat d; int ret = 0; + if (stat(basedir, &d) != 0 || !S_ISDIR(d.st_mode)) + ret = -1; + free(_storage); + return ret; } enum CompressionType get_compression(const char *flag) { |