diff options
author | ermolovd <ermolovd@yandex-team.ru> | 2022-02-10 16:47:53 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:53 +0300 |
commit | 2a4a975b112fa0fa138abc7457fe67e0e1e7fd02 (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /util | |
parent | b91bcef7c99a119b0846479ef71bfab4beec72ca (diff) | |
download | ydb-2a4a975b112fa0fa138abc7457fe67e0e1e7fd02.tar.gz |
Restoring authorship annotation for <ermolovd@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/datetime/base.h | 4 | ||||
-rw-r--r-- | util/digest/sequence.cpp | 2 | ||||
-rw-r--r-- | util/folder/path.cpp | 6 | ||||
-rw-r--r-- | util/generic/deque.h | 2 | ||||
-rw-r--r-- | util/generic/deque_ut.cpp | 8 | ||||
-rw-r--r-- | util/generic/hash.h | 50 | ||||
-rw-r--r-- | util/generic/hash_set.h | 12 | ||||
-rw-r--r-- | util/generic/hash_ut.cpp | 140 | ||||
-rw-r--r-- | util/generic/list.h | 2 | ||||
-rw-r--r-- | util/generic/list_ut.cpp | 18 | ||||
-rw-r--r-- | util/generic/map.h | 2 | ||||
-rw-r--r-- | util/generic/map_ut.cpp | 50 | ||||
-rw-r--r-- | util/generic/ptr.h | 44 | ||||
-rw-r--r-- | util/generic/ptr_ut.cpp | 104 | ||||
-rw-r--r-- | util/generic/set.h | 2 | ||||
-rw-r--r-- | util/network/socket.cpp | 28 | ||||
-rw-r--r-- | util/network/socket_ut.cpp | 72 | ||||
-rw-r--r-- | util/random/init_atfork.cpp | 2 | ||||
-rw-r--r-- | util/string/split.h | 2 | ||||
-rw-r--r-- | util/string/vector.h | 4 | ||||
-rw-r--r-- | util/system/defaults.h | 4 | ||||
-rw-r--r-- | util/system/env.cpp | 2 | ||||
-rw-r--r-- | util/system/file.cpp | 10 | ||||
-rw-r--r-- | util/system/file_ut.cpp | 54 | ||||
-rw-r--r-- | util/ya.make | 2 |
25 files changed, 313 insertions, 313 deletions
diff --git a/util/datetime/base.h b/util/datetime/base.h index 7803a80d9f..5e902b8f63 100644 --- a/util/datetime/base.h +++ b/util/datetime/base.h @@ -354,7 +354,7 @@ private: /** * private construct from microseconds since epoch */ - constexpr explicit TInstant(TValue value) noexcept + constexpr explicit TInstant(TValue value) noexcept : TBase(value) { } @@ -363,7 +363,7 @@ public: constexpr TInstant() noexcept { } - constexpr TInstant(const struct timeval& tv) noexcept + constexpr TInstant(const struct timeval& tv) noexcept : TBase(tv) { } diff --git a/util/digest/sequence.cpp b/util/digest/sequence.cpp index 05251278bf..5ab731f9bd 100644 --- a/util/digest/sequence.cpp +++ b/util/digest/sequence.cpp @@ -1 +1 @@ -#include "sequence.h" +#include "sequence.h" diff --git a/util/folder/path.cpp b/util/folder/path.cpp index 83bbfb2642..bfe0c67d68 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -427,7 +427,7 @@ void TFsPath::CopyTo(const TString& newPath, bool force) const { if (force) { TFsPath(newPath).MkDirs(); } else if (!TFsPath(newPath).IsDirectory()) { - ythrow TIoException() << "Target path is not a directory " << newPath; + ythrow TIoException() << "Target path is not a directory " << newPath; } TVector<TFsPath> children; List(children); @@ -439,10 +439,10 @@ void TFsPath::CopyTo(const TString& newPath, bool force) const { TFsPath(newPath).Parent().MkDirs(); } else { if (!TFsPath(newPath).Parent().IsDirectory()) { - ythrow TIoException() << "Parent (" << TFsPath(newPath).Parent() << ") of a target path is not a directory " << newPath; + ythrow TIoException() << "Parent (" << TFsPath(newPath).Parent() << ") of a target path is not a directory " << newPath; } if (TFsPath(newPath).Exists()) { - ythrow TIoException() << "Path already exists " << newPath; + ythrow TIoException() << "Path already exists " << newPath; } } NFs::Copy(Path_, newPath); diff --git a/util/generic/deque.h b/util/generic/deque.h index f4f2e8baa8..2dabaf3177 100644 --- a/util/generic/deque.h +++ b/util/generic/deque.h @@ -6,7 +6,7 @@ #include <deque> #include <memory> -#include <initializer_list> +#include <initializer_list> template <class T, class A> class TDeque: public std::deque<T, TReboundAllocator<A, T>> { diff --git a/util/generic/deque_ut.cpp b/util/generic/deque_ut.cpp index f1b71c3ca8..93bf50fa92 100644 --- a/util/generic/deque_ut.cpp +++ b/util/generic/deque_ut.cpp @@ -59,10 +59,10 @@ void TDequeTest::TestConstructorsAndAssignments() { UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); UNIT_ASSERT_VALUES_EQUAL(400, c3.at(3)); - - int array[] = {2, 3, 4}; - container c4 = {2, 3, 4}; - UNIT_ASSERT_VALUES_EQUAL(c4, container(std::begin(array), std::end(array))); + + int array[] = {2, 3, 4}; + container c4 = {2, 3, 4}; + UNIT_ASSERT_VALUES_EQUAL(c4, container(std::begin(array), std::end(array))); } void TDequeTest::TestDeque1() { diff --git a/util/generic/hash.h b/util/generic/hash.h index 1ae5b8c476..e46db21fa9 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -12,9 +12,9 @@ #include "utility.h" #include <algorithm> -#include <initializer_list> -#include <memory> -#include <tuple> +#include <initializer_list> +#include <memory> +#include <tuple> #include <utility> #include <cstdlib> @@ -1834,13 +1834,13 @@ public: } THashMultiMap(std::initializer_list<std::pair<Key, T>> list) - : rep(list.size(), hasher(), key_equal()) - { - for (const auto& v : list) { - rep.emplace_equal_noresize(v); - } - } - + : rep(list.size(), hasher(), key_equal()) + { + for (const auto& v : list) { + rep.emplace_equal_noresize(v); + } + } + // THashMultiMap has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. // See hash_ut.cpp @@ -1996,25 +1996,25 @@ public: template <class Key, class T, class HF, class EqKey, class Alloc> inline bool operator==(const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm1, const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm2) { - // NOTE: copy-pasted from - // contrib/libs/cxxsupp/libcxx/include/unordered_map + // NOTE: copy-pasted from + // contrib/libs/cxxsupp/libcxx/include/unordered_map // and adapted to THashMultiMap - if (hm1.size() != hm2.size()) { - return false; - } + if (hm1.size() != hm2.size()) { + return false; + } using const_iterator = typename THashMultiMap<Key, T, HF, EqKey, Alloc>::const_iterator; - using TEqualRange = std::pair<const_iterator, const_iterator>; - for (const_iterator it = hm1.begin(), end = hm1.end(); it != end;) { - TEqualRange eq1 = hm1.equal_range(it->first); - TEqualRange eq2 = hm2.equal_range(it->first); - if (std::distance(eq1.first, eq1.second) != std::distance(eq2.first, eq2.second) || + using TEqualRange = std::pair<const_iterator, const_iterator>; + for (const_iterator it = hm1.begin(), end = hm1.end(); it != end;) { + TEqualRange eq1 = hm1.equal_range(it->first); + TEqualRange eq2 = hm2.equal_range(it->first); + if (std::distance(eq1.first, eq1.second) != std::distance(eq2.first, eq2.second) || !std::is_permutation(eq1.first, eq1.second, eq2.first)) { - return false; - } - it = eq1.second; - } - return true; + return false; + } + it = eq1.second; + } + return true; } template <class Key, class T, class HF, class EqKey, class Alloc> diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h index 66c9bd5167..e8088cf23b 100644 --- a/util/generic/hash_set.h +++ b/util/generic/hash_set.h @@ -64,7 +64,7 @@ public: } THashSet(std::initializer_list<value_type> list) - : rep(list.size(), hasher(), key_equal()) + : rep(list.size(), hasher(), key_equal()) { rep.insert_unique(list.begin(), list.end()); } @@ -355,11 +355,11 @@ public: } THashMultiSet(std::initializer_list<value_type> list) - : rep(list.size(), hasher(), key_equal()) - { - rep.insert_equal(list.begin(), list.end()); - } - + : rep(list.size(), hasher(), key_equal()) + { + rep.insert_equal(list.begin(), list.end()); + } + // THashMultiSet has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. // See hash_ut.cpp diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 98f6fdaee5..0551d58770 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -16,7 +16,7 @@ class THashTest: public TTestBase { UNIT_TEST(TestHMapConstructorsAndAssignments); UNIT_TEST(TestHMap1); UNIT_TEST(TestHMapEqualityOperator); - UNIT_TEST(TestHMMapEqualityOperator); + UNIT_TEST(TestHMMapEqualityOperator); UNIT_TEST(TestHMMapConstructorsAndAssignments); UNIT_TEST(TestHMMap1); UNIT_TEST(TestHMMapHas); @@ -53,10 +53,10 @@ class THashTest: public TTestBase { UNIT_TEST(TestAssignmentClear); UNIT_TEST(TestReleaseNodes); UNIT_TEST(TestAt); - UNIT_TEST(TestHMapInitializerList); - UNIT_TEST(TestHMMapInitializerList); - UNIT_TEST(TestHSetInitializerList); - UNIT_TEST(TestHMSetInitializerList); + UNIT_TEST(TestHMapInitializerList); + UNIT_TEST(TestHMMapInitializerList); + UNIT_TEST(TestHSetInitializerList); + UNIT_TEST(TestHMSetInitializerList); UNIT_TEST(TestHSetInsertInitializerList); UNIT_TEST(TestTupleHash); UNIT_TEST_SUITE_END(); @@ -67,7 +67,7 @@ protected: void TestHMapConstructorsAndAssignments(); void TestHMap1(); void TestHMapEqualityOperator(); - void TestHMMapEqualityOperator(); + void TestHMMapEqualityOperator(); void TestHMMapConstructorsAndAssignments(); void TestHMMap1(); void TestHMMapHas(); @@ -104,10 +104,10 @@ protected: void TestAssignmentClear(); void TestReleaseNodes(); void TestAt(); - void TestHMapInitializerList(); - void TestHMMapInitializerList(); - void TestHSetInitializerList(); - void TestHMSetInitializerList(); + void TestHMapInitializerList(); + void TestHMMapInitializerList(); + void TestHSetInitializerList(); + void TestHMSetInitializerList(); void TestHSetInsertInitializerList(); void TestTupleHash(); }; @@ -225,41 +225,41 @@ void THashTest::TestHMapEqualityOperator() { UNIT_ASSERT(c3 != base); } -void THashTest::TestHMMapEqualityOperator() { +void THashTest::TestHMMapEqualityOperator() { using container = THashMultiMap<TString, int>; - using value = container::value_type; - - container base; - base.insert(value("one", 1)); - base.insert(value("one", -1)); - base.insert(value("two", 2)); - - container c1(base); - UNIT_ASSERT(c1 == base); - - container c2; - c2.insert(value("two", 2)); - c2.insert(value("one", -1)); - c2.insert(value("one", 1)); - UNIT_ASSERT(c2 == base); - - c2.insert(value("three", 3)); - UNIT_ASSERT(c2 != base); - - container c3; - c3.insert(value("one", 0)); - c3.insert(value("one", -1)); - c3.insert(value("two", 2)); - UNIT_ASSERT(c3 != base); - - container c4; - c4.insert(value("one", 1)); - c4.insert(value("one", -1)); - c4.insert(value("one", 0)); - c4.insert(value("two", 2)); - UNIT_ASSERT(c3 != base); -} - + using value = container::value_type; + + container base; + base.insert(value("one", 1)); + base.insert(value("one", -1)); + base.insert(value("two", 2)); + + container c1(base); + UNIT_ASSERT(c1 == base); + + container c2; + c2.insert(value("two", 2)); + c2.insert(value("one", -1)); + c2.insert(value("one", 1)); + UNIT_ASSERT(c2 == base); + + c2.insert(value("three", 3)); + UNIT_ASSERT(c2 != base); + + container c3; + c3.insert(value("one", 0)); + c3.insert(value("one", -1)); + c3.insert(value("two", 2)); + UNIT_ASSERT(c3 != base); + + container c4; + c4.insert(value("one", 1)); + c4.insert(value("one", -1)); + c4.insert(value("one", 0)); + c4.insert(value("two", 2)); + UNIT_ASSERT(c3 != base); +} + void THashTest::TestHMMapConstructorsAndAssignments() { using container = THashMultiMap<TString, int>; @@ -1147,46 +1147,46 @@ void THashTest::TestAt() { #undef TEST_AT_THROWN_EXCEPTION } - -void THashTest::TestHMapInitializerList() { + +void THashTest::TestHMapInitializerList() { THashMap<TString, TString> h1 = {{"foo", "bar"}, {"bar", "baz"}, {"baz", "qux"}}; THashMap<TString, TString> h2; h2.insert(std::pair<TString, TString>("foo", "bar")); h2.insert(std::pair<TString, TString>("bar", "baz")); h2.insert(std::pair<TString, TString>("baz", "qux")); - UNIT_ASSERT_EQUAL(h1, h2); -} - -void THashTest::TestHMMapInitializerList() { + UNIT_ASSERT_EQUAL(h1, h2); +} + +void THashTest::TestHMMapInitializerList() { THashMultiMap<TString, TString> h1 = { - {"foo", "bar"}, - {"foo", "baz"}, - {"baz", "qux"}}; + {"foo", "bar"}, + {"foo", "baz"}, + {"baz", "qux"}}; THashMultiMap<TString, TString> h2; h2.insert(std::pair<TString, TString>("foo", "bar")); h2.insert(std::pair<TString, TString>("foo", "baz")); h2.insert(std::pair<TString, TString>("baz", "qux")); - UNIT_ASSERT_EQUAL(h1, h2); -} - -void THashTest::TestHSetInitializerList() { + UNIT_ASSERT_EQUAL(h1, h2); +} + +void THashTest::TestHSetInitializerList() { THashSet<TString> h1 = {"foo", "bar", "baz"}; THashSet<TString> h2; - h2.insert("foo"); - h2.insert("bar"); - h2.insert("baz"); - UNIT_ASSERT_EQUAL(h1, h2); -} - -void THashTest::TestHMSetInitializerList() { + h2.insert("foo"); + h2.insert("bar"); + h2.insert("baz"); + UNIT_ASSERT_EQUAL(h1, h2); +} + +void THashTest::TestHMSetInitializerList() { THashMultiSet<TString> h1 = {"foo", "foo", "bar", "baz"}; THashMultiSet<TString> h2; - h2.insert("foo"); - h2.insert("foo"); - h2.insert("bar"); - h2.insert("baz"); - UNIT_ASSERT_EQUAL(h1, h2); -} + h2.insert("foo"); + h2.insert("foo"); + h2.insert("bar"); + h2.insert("baz"); + UNIT_ASSERT_EQUAL(h1, h2); +} namespace { struct TFoo { diff --git a/util/generic/list.h b/util/generic/list.h index ddeb94be92..7b0b8ffc72 100644 --- a/util/generic/list.h +++ b/util/generic/list.h @@ -4,7 +4,7 @@ #include <util/memory/alloc.h> -#include <initializer_list> +#include <initializer_list> #include <list> #include <memory> #include <utility> diff --git a/util/generic/list_ut.cpp b/util/generic/list_ut.cpp index 7101ee1843..9e60ecf01b 100644 --- a/util/generic/list_ut.cpp +++ b/util/generic/list_ut.cpp @@ -1,14 +1,14 @@ -#include "list.h" - +#include "list.h" + #include <library/cpp/testing/unittest/registar.h> - + Y_UNIT_TEST_SUITE(TYListSuite) { Y_UNIT_TEST(TestInitializerList) { TList<int> l = {3, 42, 6}; TList<int> expected; - expected.push_back(3); - expected.push_back(42); - expected.push_back(6); - UNIT_ASSERT_VALUES_EQUAL(l, expected); - } -} + expected.push_back(3); + expected.push_back(42); + expected.push_back(6); + UNIT_ASSERT_VALUES_EQUAL(l, expected); + } +} diff --git a/util/generic/map.h b/util/generic/map.h index 81698d753a..b5001b56c0 100644 --- a/util/generic/map.h +++ b/util/generic/map.h @@ -7,7 +7,7 @@ #include <util/memory/alloc.h> #include <utility> -#include <initializer_list> +#include <initializer_list> #include <map> #include <memory> diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 8e01c8f365..79e832b024 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -445,37 +445,37 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT_VALUES_EQUAL(values[2], 101); } } - + Y_UNIT_TEST(TestMapInitializerList) { TMap<TString, int> m = { - {"one", 1}, - {"two", 2}, - {"three", 3}, - {"four", 4}, - }; - - UNIT_ASSERT_VALUES_EQUAL(m.size(), 4); - UNIT_ASSERT_VALUES_EQUAL(m["one"], 1); - UNIT_ASSERT_VALUES_EQUAL(m["two"], 2); - UNIT_ASSERT_VALUES_EQUAL(m["three"], 3); - UNIT_ASSERT_VALUES_EQUAL(m["four"], 4); - } - + {"one", 1}, + {"two", 2}, + {"three", 3}, + {"four", 4}, + }; + + UNIT_ASSERT_VALUES_EQUAL(m.size(), 4); + UNIT_ASSERT_VALUES_EQUAL(m["one"], 1); + UNIT_ASSERT_VALUES_EQUAL(m["two"], 2); + UNIT_ASSERT_VALUES_EQUAL(m["three"], 3); + UNIT_ASSERT_VALUES_EQUAL(m["four"], 4); + } + Y_UNIT_TEST(TestMMapInitializerList) { TMultiMap<TString, int> mm = { - {"one", 1}, - {"two", 2}, - {"two", -2}, - {"three", 3}, - }; + {"one", 1}, + {"two", 2}, + {"two", -2}, + {"three", 3}, + }; UNIT_ASSERT(mm.contains("two")); TMultiMap<TString, int> expected; - expected.emplace("one", 1); - expected.emplace("two", 2); - expected.emplace("two", -2); - expected.emplace("three", 3); - UNIT_ASSERT_VALUES_EQUAL(mm, expected); - } + expected.emplace("one", 1); + expected.emplace("two", 2); + expected.emplace("two", -2); + expected.emplace("three", 3); + UNIT_ASSERT_VALUES_EQUAL(mm, expected); + } Y_UNIT_TEST(TestMovePoolAlloc) { using TMapInPool = TMap<int, int, TLess<int>, TPoolAllocator>; diff --git a/util/generic/ptr.h b/util/generic/ptr.h index fa15f3a378..19db0e3ec5 100644 --- a/util/generic/ptr.h +++ b/util/generic/ptr.h @@ -4,7 +4,7 @@ #include "utility.h" #include "intrlist.h" #include "refcount.h" -#include "typetraits.h" +#include "typetraits.h" #include "singleton.h" #include <utility> @@ -508,22 +508,22 @@ public: Ref(); } - // NOTE: + // NOTE: // without std::enable_if_t compiler sometimes tries to use this constructor inappropriately - // e.g. - // struct A {}; - // struct B {}; - // void Func(TIntrusivePtr<A>); - // void Func(TIntrusivePtr<B>); - // ... - // Func(TIntrusivePtr<A>(new A)); // <--- compiler can't decide which version of Func to use + // e.g. + // struct A {}; + // struct B {}; + // void Func(TIntrusivePtr<A>); + // void Func(TIntrusivePtr<B>); + // ... + // Func(TIntrusivePtr<A>(new A)); // <--- compiler can't decide which version of Func to use template <class U, class = TGuardConversion<T, U>> inline TIntrusivePtr(const TIntrusivePtr<U>& p) noexcept - : T_(p.Get()) - { - Ref(); - } - + : T_(p.Get()) + { + Ref(); + } + template <class U, class = TGuardConversion<T, U>> inline TIntrusivePtr(TIntrusivePtr<U>&& p) noexcept : T_(p.T_) @@ -645,11 +645,11 @@ public: template <class U, class = TGuardConversion<T, U>> inline TIntrusiveConstPtr(const TIntrusiveConstPtr<U>& p) noexcept - : T_(p.T_) - { - Ref(); - } - + : T_(p.T_) + { + Ref(); + } + template <class U, class = TGuardConversion<T, U>> inline TIntrusiveConstPtr(TIntrusiveConstPtr<U>&& p) noexcept : T_(p.T_) @@ -711,9 +711,9 @@ private: private: T* T_; - - template <class U, class O> - friend class TIntrusiveConstPtr; + + template <class U, class O> + friend class TIntrusiveConstPtr; }; template <class T, class Ops> diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp index a53f819c1f..c2dcff23f6 100644 --- a/util/generic/ptr_ut.cpp +++ b/util/generic/ptr_ut.cpp @@ -23,8 +23,8 @@ class TPointerTest: public TTestBase { UNIT_TEST(TestAutoToHolder); UNIT_TEST(TestCopyPtr); UNIT_TEST(TestIntrPtr); - UNIT_TEST(TestIntrusiveConvertion); - UNIT_TEST(TestIntrusiveConstConvertion); + UNIT_TEST(TestIntrusiveConvertion); + UNIT_TEST(TestIntrusiveConstConvertion); UNIT_TEST(TestIntrusiveConstConstruction); UNIT_TEST(TestMakeIntrusive); UNIT_TEST(TestCopyOnWritePtr1); @@ -75,8 +75,8 @@ private: void TestAutoToHolder(); void TestCopyPtr(); void TestIntrPtr(); - void TestIntrusiveConvertion(); - void TestIntrusiveConstConvertion(); + void TestIntrusiveConvertion(); + void TestIntrusiveConstConvertion(); void TestIntrusiveConstConstruction(); void TestMakeIntrusive(); void TestCopyOnWritePtr1(); @@ -364,59 +364,59 @@ void TPointerTest::TestIntrPtr() { UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 0); } -namespace NTestIntrusiveConvertion { +namespace NTestIntrusiveConvertion { struct TA: public TSimpleRefCount<TA> { - }; + }; struct TAA: public TA { - }; + }; struct TB: public TSimpleRefCount<TB> { - }; - - void Func(TIntrusivePtr<TA>) { - } - - void Func(TIntrusivePtr<TB>) { - } - - void Func(TIntrusiveConstPtr<TA>) { - } - - void Func(TIntrusiveConstPtr<TB>) { - } -} - + }; + + void Func(TIntrusivePtr<TA>) { + } + + void Func(TIntrusivePtr<TB>) { + } + + void Func(TIntrusiveConstPtr<TA>) { + } + + void Func(TIntrusiveConstPtr<TB>) { + } +} + void TPointerTest::TestIntrusiveConvertion() { - using namespace NTestIntrusiveConvertion; - - TIntrusivePtr<TAA> aa = new TAA; - - UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 1); - TIntrusivePtr<TA> a = aa; - UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 2); - UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 2); - aa.Reset(); - UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 1); - - // test that Func(TIntrusivePtr<TB>) doesn't participate in overload resolution - Func(aa); -} - + using namespace NTestIntrusiveConvertion; + + TIntrusivePtr<TAA> aa = new TAA; + + UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 1); + TIntrusivePtr<TA> a = aa; + UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 2); + UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 2); + aa.Reset(); + UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 1); + + // test that Func(TIntrusivePtr<TB>) doesn't participate in overload resolution + Func(aa); +} + void TPointerTest::TestIntrusiveConstConvertion() { - using namespace NTestIntrusiveConvertion; - - TIntrusiveConstPtr<TAA> aa = new TAA; - - UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 1); - TIntrusiveConstPtr<TA> a = aa; - UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 2); - UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 2); - aa.Reset(); - UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 1); - - // test that Func(TIntrusiveConstPtr<TB>) doesn't participate in overload resolution - Func(aa); -} - + using namespace NTestIntrusiveConvertion; + + TIntrusiveConstPtr<TAA> aa = new TAA; + + UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 1); + TIntrusiveConstPtr<TA> a = aa; + UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 2); + UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 2); + aa.Reset(); + UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 1); + + // test that Func(TIntrusiveConstPtr<TB>) doesn't participate in overload resolution + Func(aa); +} + void TPointerTest::TestMakeIntrusive() { { UNIT_ASSERT_VALUES_EQUAL(0, TOp::Cnt); diff --git a/util/generic/set.h b/util/generic/set.h index 575d16d064..4c437ca26f 100644 --- a/util/generic/set.h +++ b/util/generic/set.h @@ -5,7 +5,7 @@ #include <util/str_stl.h> #include <util/memory/alloc.h> -#include <initializer_list> +#include <initializer_list> #include <memory> #include <set> diff --git a/util/network/socket.cpp b/util/network/socket.cpp index cec676b032..4f6e804346 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -538,19 +538,19 @@ ESocketReadStatus HasSocketDataToRead(SOCKET s) { } #if defined(_win_) -static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) { +static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) { return writev(sock, iov, iovcnt); -} -#else -static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) { - struct msghdr message; - - Zero(message); - message.msg_iov = const_cast<struct iovec*>(iov); - message.msg_iovlen = iovcnt; - - return sendmsg(sock, &message, MSG_NOSIGNAL); -} +} +#else +static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) { + struct msghdr message; + + Zero(message); + message.msg_iov = const_cast<struct iovec*>(iov); + message.msg_iovlen = iovcnt; + + return sendmsg(sock, &message, MSG_NOSIGNAL); +} #endif void TSocketHolder::Close() noexcept { @@ -709,7 +709,7 @@ static inline SOCKET DoConnect(const struct addrinfo* res, const TInstant& deadL static inline ssize_t DoSendV(SOCKET fd, const struct iovec* iov, size_t count) { ssize_t ret = -1; do { - ret = DoSendMsg(fd, iov, (int)count); + ret = DoSendMsg(fd, iov, (int)count); } while (ret == -1 && errno == EINTR); if (ret < 0) { @@ -760,7 +760,7 @@ public: ssize_t Send(SOCKET fd, const void* data, size_t len) override { ssize_t ret = -1; do { - ret = send(fd, (const char*)data, (int)len, MSG_NOSIGNAL); + ret = send(fd, (const char*)data, (int)len, MSG_NOSIGNAL); } while (ret == -1 && errno == EINTR); if (ret < 0) { diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp index 5980c7d370..6b20e11f70 100644 --- a/util/network/socket_ut.cpp +++ b/util/network/socket_ut.cpp @@ -1,7 +1,7 @@ #include "socket.h" -#include "pair.h" - +#include "pair.h" + #include <library/cpp/testing/unittest/registar.h> #include <util/string/builder.h> @@ -23,7 +23,7 @@ class TSockTest: public TTestBase { #endif UNIT_TEST(TestNetworkResolutionError); UNIT_TEST(TestNetworkResolutionErrorMessage); - UNIT_TEST(TestBrokenPipe); + UNIT_TEST(TestBrokenPipe); UNIT_TEST(TestClose); UNIT_TEST(TestReusePortAvailCheck); UNIT_TEST_SUITE_END(); @@ -34,7 +34,7 @@ public: void TestConnectionRefused(); void TestNetworkResolutionError(); void TestNetworkResolutionErrorMessage(); - void TestBrokenPipe(); + void TestBrokenPipe(); void TestClose(); void TestReusePortAvailCheck(); }; @@ -129,43 +129,43 @@ void TSockTest::TestNetworkResolutionErrorMessage() { } class TTempEnableSigPipe { -public: - TTempEnableSigPipe() { +public: + TTempEnableSigPipe() { OriginalSigHandler_ = signal(SIGPIPE, SIG_DFL); Y_VERIFY(OriginalSigHandler_ != SIG_ERR); - } - - ~TTempEnableSigPipe() { + } + + ~TTempEnableSigPipe() { auto ret = signal(SIGPIPE, OriginalSigHandler_); - Y_VERIFY(ret != SIG_ERR); - } - -private: + Y_VERIFY(ret != SIG_ERR); + } + +private: void (*OriginalSigHandler_)(int); -}; - +}; + void TSockTest::TestBrokenPipe() { - TTempEnableSigPipe guard; - - SOCKET socks[2]; - - int ret = SocketPair(socks); - UNIT_ASSERT_VALUES_EQUAL(ret, 0); - - TSocket sender(socks[0]); - TSocket receiver(socks[1]); - receiver.ShutDown(SHUT_RDWR); - int sent = sender.Send("FOO", 3); - UNIT_ASSERT(sent < 0); - - IOutputStream::TPart parts[] = { - {"foo", 3}, - {"bar", 3}, - }; - sent = sender.SendV(parts, 2); - UNIT_ASSERT(sent < 0); -} - + TTempEnableSigPipe guard; + + SOCKET socks[2]; + + int ret = SocketPair(socks); + UNIT_ASSERT_VALUES_EQUAL(ret, 0); + + TSocket sender(socks[0]); + TSocket receiver(socks[1]); + receiver.ShutDown(SHUT_RDWR); + int sent = sender.Send("FOO", 3); + UNIT_ASSERT(sent < 0); + + IOutputStream::TPart parts[] = { + {"foo", 3}, + {"bar", 3}, + }; + sent = sender.SendV(parts, 2); + UNIT_ASSERT(sent < 0); +} + void TSockTest::TestClose() { SOCKET socks[2]; diff --git a/util/random/init_atfork.cpp b/util/random/init_atfork.cpp index 5cb74a1ab1..0faa3d119a 100644 --- a/util/random/init_atfork.cpp +++ b/util/random/init_atfork.cpp @@ -15,7 +15,7 @@ namespace { (void)&AtFork; #if defined(_unix_) - Y_VERIFY(pthread_atfork(nullptr, AtFork, nullptr) == 0, "it happens"); + Y_VERIFY(pthread_atfork(nullptr, AtFork, nullptr) == 0, "it happens"); #endif } diff --git a/util/string/split.h b/util/string/split.h index 50aaccad5e..bc46d9e64c 100644 --- a/util/string/split.h +++ b/util/string/split.h @@ -18,7 +18,7 @@ #include <utility> #include <stlfwd> - + // NOTE: Check StringSplitter below to get more convenient split string interface. namespace NStringSplitPrivate { diff --git a/util/string/vector.h b/util/string/vector.h index 4f142de6b3..e36c348bbe 100644 --- a/util/string/vector.h +++ b/util/string/vector.h @@ -12,9 +12,9 @@ #define KEEP_EMPTY_TOKENS 0x01 -// +// // NOTE: Check StringSplitter below to get more convenient split string interface. - + namespace NPrivate { void SplitStringImpl(TVector<TString>* res, const char* ptr, diff --git a/util/system/defaults.h b/util/system/defaults.h index 02e786b7c2..dcd7abea38 100644 --- a/util/system/defaults.h +++ b/util/system/defaults.h @@ -130,10 +130,10 @@ constexpr bool Y_IS_DEBUG_BUILD = true; #undef Y_ARRAY_BEGIN #define Y_ARRAY_BEGIN(arr) (arr) - + #undef Y_ARRAY_END #define Y_ARRAY_END(arr) ((arr) + Y_ARRAY_SIZE(arr)) - + /** * Concatenates two symbols, even if one of them is itself a macro. */ diff --git a/util/system/env.cpp b/util/system/env.cpp index fc44e64c2e..ead9b566a5 100644 --- a/util/system/env.cpp +++ b/util/system/env.cpp @@ -1,7 +1,7 @@ #include "env.h" #include <util/generic/string.h> -#include <util/generic/yexception.h> +#include <util/generic/yexception.h> #ifdef _win_ #include <util/generic/vector.h> diff --git a/util/system/file.cpp b/util/system/file.cpp index 76b033cee2..4a261d020c 100644 --- a/util/system/file.cpp +++ b/util/system/file.cpp @@ -425,8 +425,8 @@ bool TFileHandle::Flush() noexcept { */ return ok || GetLastError() == ERROR_INVALID_HANDLE; #elif defined(_unix_) - int ret = ::fsync(Fd_); - + int ret = ::fsync(Fd_); + /* * Ignore EROFS, EINVAL - fd is bound to a special file * (PIPE, FIFO, or socket) which does not support synchronization. @@ -449,10 +449,10 @@ bool TFileHandle::FlushData() noexcept { return false; } - int ret = ::fdatasync(Fd_); - + int ret = ::fdatasync(Fd_); + // Same loginc in error handling as for fsync above. - return ret == 0 || errno == EROFS || errno == EINVAL; + return ret == 0 || errno == EROFS || errno == EINVAL; #else return Flush(); #endif diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp index 07b2b7a96d..941e6a50f3 100644 --- a/util/system/file_ut.cpp +++ b/util/system/file_ut.cpp @@ -17,8 +17,8 @@ class TFileTest: public TTestBase { UNIT_TEST(TestLinkTo); UNIT_TEST(TestResize); UNIT_TEST(TestLocale); - UNIT_TEST(TestFlush); - UNIT_TEST(TestFlushSpecialFile); + UNIT_TEST(TestFlush); + UNIT_TEST(TestFlushSpecialFile); UNIT_TEST(TestRawRead); UNIT_TEST(TestRead); UNIT_TEST(TestRawPread); @@ -31,8 +31,8 @@ public: void TestOpenSync(); void TestRW(); void TestLocale(); - void TestFlush(); - void TestFlushSpecialFile(); + void TestFlush(); + void TestFlushSpecialFile(); void TestRawRead(); void TestRead(); void TestRawPread(); @@ -216,29 +216,29 @@ void TFileTest::TestLocale() { #endif } -void TFileTest::TestFlush() { - TTempFile tmp("tmp"); - - { - TFile f(tmp.Name(), OpenAlways | WrOnly); - f.Flush(); - f.FlushData(); - f.Close(); - - UNIT_ASSERT_EXCEPTION(f.Flush(), TFileError); - UNIT_ASSERT_EXCEPTION(f.FlushData(), TFileError); - } -} - -void TFileTest::TestFlushSpecialFile() { -#ifdef _unix_ - TFile devNull("/dev/null", WrOnly); - devNull.FlushData(); - devNull.Flush(); - devNull.Close(); -#endif -} - +void TFileTest::TestFlush() { + TTempFile tmp("tmp"); + + { + TFile f(tmp.Name(), OpenAlways | WrOnly); + f.Flush(); + f.FlushData(); + f.Close(); + + UNIT_ASSERT_EXCEPTION(f.Flush(), TFileError); + UNIT_ASSERT_EXCEPTION(f.FlushData(), TFileError); + } +} + +void TFileTest::TestFlushSpecialFile() { +#ifdef _unix_ + TFile devNull("/dev/null", WrOnly); + devNull.FlushData(); + devNull.Flush(); + devNull.Close(); +#endif +} + void TFileTest::TestRawRead() { TTempFile tmp("tmp"); diff --git a/util/ya.make b/util/ya.make index 451774a976..6ebe7e40cf 100644 --- a/util/ya.make +++ b/util/ya.make @@ -49,7 +49,7 @@ JOIN_SRCS( digest/multi.cpp digest/murmur.cpp digest/numeric.cpp - digest/sequence.cpp + digest/sequence.cpp ) JOIN_SRCS( |