diff options
author | Vasily Gerasimov <UgnineSirdis@gmail.com> | 2022-02-10 16:49:10 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:10 +0300 |
commit | 1eb755fbca92172a6aec2f57371b2b3a19dfab43 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/folder | |
parent | 6cdc8f140213c595e4ad38bc3d97fcef1146b8c3 (diff) | |
download | ydb-1eb755fbca92172a6aec2f57371b2b3a19dfab43.tar.gz |
Restoring authorship annotation for Vasily Gerasimov <UgnineSirdis@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/folder')
-rw-r--r-- | util/folder/fts.cpp | 18 | ||||
-rw-r--r-- | util/folder/fts_ut.cpp | 82 | ||||
-rw-r--r-- | util/folder/iterator_ut.cpp | 2 | ||||
-rw-r--r-- | util/folder/path.cpp | 4 | ||||
-rw-r--r-- | util/folder/tempdir.cpp | 2 |
5 files changed, 54 insertions, 54 deletions
diff --git a/util/folder/fts.cpp b/util/folder/fts.cpp index bcdad0c652..0e6a6f86eb 100644 --- a/util/folder/fts.cpp +++ b/util/folder/fts.cpp @@ -249,12 +249,12 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con errno = 0; - Y_ASSERT(argv); - if (!*argv) { - errno = ENOENT; - return nullptr; - } - + Y_ASSERT(argv); + if (!*argv) { + errno = ENOENT; + return nullptr; + } + /* Options check. */ if (options & ~FTS_OPTIONMASK) { errno = EINVAL; @@ -991,7 +991,7 @@ fts_build(FTS* sp, int type) } #endif - // coverity[dead_error_line]: false positive + // coverity[dead_error_line]: false positive if (cderrno) { if (nlinks) { p->fts_info = FTS_NS; @@ -1075,7 +1075,7 @@ fts_build(FTS* sp, int type) (cur->fts_level == FTS_ROOTLEVEL ? FCHDIR(sp, sp->fts_rfd) : fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { cur->fts_info = FTS_ERR; SET(FTS_STOP); - fts_lfree(head); + fts_lfree(head); return nullptr; } @@ -1084,7 +1084,7 @@ fts_build(FTS* sp, int type) if (type == BREAD) { cur->fts_info = FTS_DP; } - fts_lfree(head); + fts_lfree(head); return nullptr; } diff --git a/util/folder/fts_ut.cpp b/util/folder/fts_ut.cpp index a8145bdd48..c5d59e35f4 100644 --- a/util/folder/fts_ut.cpp +++ b/util/folder/fts_ut.cpp @@ -3,7 +3,7 @@ #include "tempdir.h" #include <library/cpp/testing/unittest/registar.h> -#include <library/cpp/threading/future/async.h> +#include <library/cpp/threading/future/async.h> #include <util/system/file.h> #include <util/system/tempfile.h> @@ -12,12 +12,12 @@ class TFtsTest: public TTestBase { UNIT_TEST_SUITE(TFtsTest); UNIT_TEST(TestSimple); - UNIT_TEST(TestNoLeakChangingAccessToFolder); + UNIT_TEST(TestNoLeakChangingAccessToFolder); UNIT_TEST_SUITE_END(); public: void TestSimple(); - void TestNoLeakChangingAccessToFolder(); + void TestNoLeakChangingAccessToFolder(); }; void MakeFile(const char* path) { @@ -82,42 +82,42 @@ void TFtsTest::TestSimple() { UNIT_ASSERT_EQUAL(yfts_read(fileTree()), nullptr); } -class TTempDirWithLostAccess: public TTempDir { -public: - ~TTempDirWithLostAccess() { - chmod(Name().data(), 0777); - } -}; - -// https://st.yandex-team.ru/YQ-318 -// Test that detects memory leak in case of error in chdir in fts_build function. -void TFtsTest::TestNoLeakChangingAccessToFolder() { - TTempDirWithLostAccess tempDir; - TString tmpPath = tempDir(); - if (tmpPath.EndsWith(LOCSLASH_S)) { - tmpPath.resize(tmpPath.size() - 1); - } - MakeDirIfNotExist((tmpPath + LOCSLASH_S + "subdir").data()); - - const char* path[2] = {tmpPath.data(), nullptr}; - TFileTree fileTree((char* const*)path, FTS_SEEDOT, FtsCmp); - UNIT_ASSERT(fileTree()); - - CheckEnt(yfts_read(fileTree()), tmpPath.data(), FTS_D); -#ifndef _win32_ - CheckEnt(yfts_read(fileTree()), (tmpPath + LOCSLASH_S ".").data(), FTS_DOT); -#endif // _win32_ - CheckEnt(yfts_read(fileTree()), (tmpPath + LOCSLASH_S "..").data(), FTS_DOT); - CheckEnt(yfts_read(fileTree()), (tmpPath + LOCSLASH_S "subdir").data(), FTS_D); - auto pool = CreateThreadPool(2); - auto chmodFuture = NThreading::Async([name = tmpPath] { - UNIT_ASSERT_C(!chmod(name.data(), 0), "Errno: " << errno); - }, *pool); - auto childrenFuture = NThreading::Async([&] { - yfts_children(fileTree(), 0); - }, *pool); - childrenFuture.Wait(); - chmodFuture.Wait(); -} - +class TTempDirWithLostAccess: public TTempDir { +public: + ~TTempDirWithLostAccess() { + chmod(Name().data(), 0777); + } +}; + +// https://st.yandex-team.ru/YQ-318 +// Test that detects memory leak in case of error in chdir in fts_build function. +void TFtsTest::TestNoLeakChangingAccessToFolder() { + TTempDirWithLostAccess tempDir; + TString tmpPath = tempDir(); + if (tmpPath.EndsWith(LOCSLASH_S)) { + tmpPath.resize(tmpPath.size() - 1); + } + MakeDirIfNotExist((tmpPath + LOCSLASH_S + "subdir").data()); + + const char* path[2] = {tmpPath.data(), nullptr}; + TFileTree fileTree((char* const*)path, FTS_SEEDOT, FtsCmp); + UNIT_ASSERT(fileTree()); + + CheckEnt(yfts_read(fileTree()), tmpPath.data(), FTS_D); +#ifndef _win32_ + CheckEnt(yfts_read(fileTree()), (tmpPath + LOCSLASH_S ".").data(), FTS_DOT); +#endif // _win32_ + CheckEnt(yfts_read(fileTree()), (tmpPath + LOCSLASH_S "..").data(), FTS_DOT); + CheckEnt(yfts_read(fileTree()), (tmpPath + LOCSLASH_S "subdir").data(), FTS_D); + auto pool = CreateThreadPool(2); + auto chmodFuture = NThreading::Async([name = tmpPath] { + UNIT_ASSERT_C(!chmod(name.data(), 0), "Errno: " << errno); + }, *pool); + auto childrenFuture = NThreading::Async([&] { + yfts_children(fileTree(), 0); + }, *pool); + childrenFuture.Wait(); + chmodFuture.Wait(); +} + UNIT_TEST_SUITE_REGISTRATION(TFtsTest); diff --git a/util/folder/iterator_ut.cpp b/util/folder/iterator_ut.cpp index e4c49c9310..936becd139 100644 --- a/util/folder/iterator_ut.cpp +++ b/util/folder/iterator_ut.cpp @@ -81,7 +81,7 @@ private: inline ~TDirHier() { for (size_t i = 0; i < Paths_.size(); ++i) { - NFs::Remove(Paths_[Paths_.size() - i - 1].Path); + NFs::Remove(Paths_[Paths_.size() - i - 1].Path); } } diff --git a/util/folder/path.cpp b/util/folder/path.cpp index e16a979fc1..bfe0c67d68 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -289,7 +289,7 @@ void TFsPath::RenameTo(const TString& newPath) const { ythrow TIoException() << "bad new file name"; } if (!NFs::Rename(Path_, newPath)) { - ythrow TIoSystemError() << "failed to rename " << Path_ << " to " << newPath; + ythrow TIoSystemError() << "failed to rename " << Path_ << " to " << newPath; } } @@ -326,7 +326,7 @@ TFsPath TFsPath::ReadLink() const { ythrow TIoException() << "not a symlink " << *this; } - return NFs::ReadLink(*this); + return NFs::ReadLink(*this); } bool TFsPath::Exists() const { diff --git a/util/folder/tempdir.cpp b/util/folder/tempdir.cpp index 2587cd3f52..6fdf8f753c 100644 --- a/util/folder/tempdir.cpp +++ b/util/folder/tempdir.cpp @@ -25,7 +25,7 @@ TTempDir::TTempDir(const TString& tempDir) : TempDir(tempDir) , Remove(true) { - NFs::Remove(TempDir); + NFs::Remove(TempDir); MakeDirIfNotExist(TempDir.c_str()); } |