diff options
author | tejblum <tejblum@yandex-team.ru> | 2022-02-10 16:48:02 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:02 +0300 |
commit | 6ab7e5f5ada0643a48d393717f443bd548706ffc (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /util | |
parent | 2bf39531b4f50b889e946ac4866018678a4fb281 (diff) | |
download | ydb-6ab7e5f5ada0643a48d393717f443bd548706ffc.tar.gz |
Restoring authorship annotation for <tejblum@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/charset/recode_result.h | 2 | ||||
-rw-r--r-- | util/folder/fts.cpp | 60 | ||||
-rw-r--r-- | util/generic/map.h | 8 | ||||
-rw-r--r-- | util/generic/strbase.h | 2 | ||||
-rw-r--r-- | util/generic/string.cpp | 4 | ||||
-rw-r--r-- | util/generic/string.h | 12 | ||||
-rw-r--r-- | util/network/poller.h | 6 | ||||
-rw-r--r-- | util/network/socket.cpp | 28 | ||||
-rw-r--r-- | util/string/printf_ut.cpp | 2 | ||||
-rw-r--r-- | util/string/strip_ut.cpp | 6 | ||||
-rw-r--r-- | util/string/subst_ut.cpp | 2 | ||||
-rw-r--r-- | util/string/type_ut.cpp | 2 | ||||
-rw-r--r-- | util/string/util_ut.cpp | 8 | ||||
-rw-r--r-- | util/system/condvar.cpp | 26 | ||||
-rw-r--r-- | util/system/condvar.h | 6 | ||||
-rw-r--r-- | util/system/defaults.h | 16 | ||||
-rw-r--r-- | util/system/rwlock.cpp | 20 | ||||
-rw-r--r-- | util/system/rwlock.h | 18 | ||||
-rw-r--r-- | util/system/sem.cpp | 4 | ||||
-rw-r--r-- | util/system/tls.cpp | 2 | ||||
-rw-r--r-- | util/thread/pool.h | 2 |
21 files changed, 118 insertions, 118 deletions
diff --git a/util/charset/recode_result.h b/util/charset/recode_result.h index 54df7c02d0..2c7366e7b2 100644 --- a/util/charset/recode_result.h +++ b/util/charset/recode_result.h @@ -1,5 +1,5 @@ #pragma once - + enum RECODE_RESULT { RECODE_OK, RECODE_EOINPUT, diff --git a/util/folder/fts.cpp b/util/folder/fts.cpp index 2acc43b4a8..0e6a6f86eb 100644 --- a/util/folder/fts.cpp +++ b/util/folder/fts.cpp @@ -29,8 +29,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $ + * + * $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $ */ #include <util/memory/tempbuf.h> @@ -271,7 +271,7 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con /* Shush, GCC. */ tmp = nullptr; - + /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ if (ISSET(FTS_LOGICAL)) { SET(FTS_NOCHDIR); @@ -450,8 +450,8 @@ int yfts_close(FTS* sp) } /* - * Special case of "/" at the end of the path so that slashes aren't - * appended which would cause paths to be written as "....//foo". + * Special case of "/" at the end of the path so that slashes aren't + * appended which would cause paths to be written as "....//foo". */ #define NAPPEND(p) \ (p->fts_path[p->fts_pathlen - 1] == LOCSLASH_C \ @@ -803,14 +803,14 @@ fts_build(FTS* sp, int type) * Open the directory for reading. If this fails, we're done. * If being called from yfts_read, set the fts_info field. */ -#ifdef FTS_WHITEOUT +#ifdef FTS_WHITEOUT if (ISSET(FTS_WHITEOUT)) oflag = DTF_NODUP | DTF_REWIND; else oflag = DTF_HIDEW | DTF_NODUP | DTF_REWIND; -#else +#else #define __opendir2(path, flag) opendir(path) -#endif +#endif if ((dirp = __opendir2(cur->fts_accpath, oflag)) == nullptr) { if (type == BREAD) { cur->fts_info = FTS_DNR; @@ -976,11 +976,11 @@ fts_build(FTS* sp, int type) p->fts_parent = sp->fts_cur; p->fts_pathlen = u_short(len + strlen(dp->d_name)); -#ifdef FTS_WHITEOUT +#ifdef FTS_WHITEOUT if (dp->d_type == DT_WHT) p->fts_flags |= FTS_ISW; -#endif - +#endif + #ifdef _DIRENT_HAVE_D_TYPE if (dp->d_type == DT_DIR) { p->fts_type = FTS_D; @@ -1105,7 +1105,7 @@ fts_stat(FTS* sp, FTSENT* p, int follow) /* If user needs stat info, stat buffer already allocated. */ sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp; -#ifdef FTS_WHITEOUT +#ifdef FTS_WHITEOUT /* check for whiteout */ if (p->fts_flags & FTS_ISW) { if (sbp != &sb) { @@ -1114,8 +1114,8 @@ fts_stat(FTS* sp, FTSENT* p, int follow) } return (FTS_W); } -#endif - +#endif + /* * If doing a logical walk, or application requested FTS_FOLLOW, do * a stat(2). If that fails, check for a non-existent symlink. If @@ -1199,7 +1199,7 @@ fts_sort(FTS* sp, FTSENT* head, int nitems) */ if (nitems > sp->fts_nitems) { struct _ftsent** a; - + sp->fts_nitems = nitems + 40; if ((a = (struct _ftsent**)realloc(sp->fts_array, sp->fts_nitems * sizeof(FTSENT*))) == nullptr) { @@ -1289,9 +1289,9 @@ fts_palloc(FTS* sp, size_t more) return (sp->fts_path == nullptr); } -static void +static void ADJUST(FTSENT* p, void* addr) -{ +{ if ((p)->fts_accpath >= (p)->fts_path && (p)->fts_accpath < (p)->fts_path + (p)->fts_pathlen) { if (p->fts_accpath != p->fts_path) { @@ -1305,8 +1305,8 @@ ADJUST(FTSENT* p, void* addr) (char*)addr + ((p)->fts_accpath - (p)->fts_path); } (p)->fts_path = (char*)addr; -} - +} + /* * When the path is realloc'd, have to fix all of the pointers in structures * already returned. @@ -1347,20 +1347,20 @@ fts_maxarglen(char* const* argv) } return (max + 1); } - -/* - * Change to dir specified by fd or p->fts_accpath without getting - * tricked by someone changing the world out from underneath us. - * Assumes p->fts_dev and p->fts_ino are filled in. - */ + +/* + * Change to dir specified by fd or p->fts_accpath without getting + * tricked by someone changing the world out from underneath us. + * Assumes p->fts_dev and p->fts_ino are filled in. + */ #ifndef _win_ -static int +static int fts_safe_changedir(FTS* sp, FTSENT* p, int fd, const char* path) -{ +{ int ret, oerrno, newfd; stat_struct sb; - + newfd = fd; if (ISSET(FTS_NOCHDIR)) { return (0); @@ -1378,14 +1378,14 @@ fts_safe_changedir(FTS* sp, FTSENT* p, int fd, const char* path) goto bail; } ret = fchdir(newfd); -bail: +bail: oerrno = errno; if (fd < 0) { (void)close(newfd); } errno = oerrno; return (ret); -} +} #else static int fts_safe_changedir(FTS* sp, FTSENT* p, int /*fd*/, const char* path) diff --git a/util/generic/map.h b/util/generic/map.h index cac7358bc8..b5001b56c0 100644 --- a/util/generic/map.h +++ b/util/generic/map.h @@ -1,5 +1,5 @@ #pragma once - + #include "fwd.h" #include "mapfindptr.h" @@ -25,8 +25,8 @@ public: inline bool contains(const K& key) const { return this->find(key) != this->end(); } -}; - +}; + template <class K, class V, class Less, class A> class TMultiMap: public std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>> { using TBase = std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>; @@ -41,4 +41,4 @@ public: inline bool contains(const K& key) const { return this->find(key) != this->end(); } -}; +}; diff --git a/util/generic/strbase.h b/util/generic/strbase.h index 2db3c246db..ab39fc7537 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -1,5 +1,5 @@ #pragma once - + // Some of these includes are just a legacy from previous implementation. // We don't need them here, but removing them is tricky because it breaks all // kinds of builds downstream diff --git a/util/generic/string.cpp b/util/generic/string.cpp index 72ffda5ed1..3c655f1f66 100644 --- a/util/generic/string.cpp +++ b/util/generic/string.cpp @@ -21,8 +21,8 @@ std::istream& operator>>(std::istream& is, TString& s) { template <> bool TBasicString<char, std::char_traits<char>>::to_lower(size_t pos, size_t n) { return Transform([](size_t, char c) { return AsciiToLower(c); }, pos, n); -} - +} + template <> bool TBasicString<char, std::char_traits<char>>::to_upper(size_t pos, size_t n) { return Transform([](size_t, char c) { return AsciiToUpper(c); }, pos, n); diff --git a/util/generic/string.h b/util/generic/string.h index aacf6788de..8cd8aa6917 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -1,5 +1,5 @@ #pragma once - + #include <cstddef> #include <cstring> #include <stlfwd> @@ -370,7 +370,7 @@ public: return *this; } - + // ~~~ Constructor ~~~ : FAMILY0(,TBasicString) TBasicString() noexcept #ifndef TSTRING_IS_STD_STRING @@ -433,7 +433,7 @@ public: #endif { } - + TBasicString(const TCharType* pc) : TBasicString(pc, TBase::StrLen(pc)) { @@ -893,7 +893,7 @@ public: s1 += s2; return std::move(s1); } - + friend TBasicString operator+(TBasicString&& s1, TCharType s2) Y_WARN_UNUSED_RESULT { s1 += s2; return std::move(s1); @@ -975,7 +975,7 @@ public: return *this; } - + TBasicString& prepend(const TBasicStringBuf<TCharType, TTraits> s, size_t spos = 0, size_t sn = TBase::npos) { return insert(0, s, spos, sn); } @@ -1193,7 +1193,7 @@ public: std::ostream& operator<<(std::ostream&, const TString&); std::istream& operator>>(std::istream&, TString&); - + template <typename TCharType, typename TTraits> TBasicString<TCharType> to_lower(const TBasicString<TCharType, TTraits>& s) { TBasicString<TCharType> ret(s); diff --git a/util/network/poller.h b/util/network/poller.h index 37873e911a..8dccd73140 100644 --- a/util/network/poller.h +++ b/util/network/poller.h @@ -1,10 +1,10 @@ #pragma once - + #include "socket.h" #include <util/generic/ptr.h> #include <util/datetime/base.h> - + class TSocketPoller { public: TSocketPoller(); @@ -55,4 +55,4 @@ public: private: class TImpl; THolder<TImpl> Impl_; -}; +}; diff --git a/util/network/socket.cpp b/util/network/socket.cpp index d9266af546..4f6e804346 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -64,16 +64,16 @@ int inet_aton(const char* cp, struct in_addr* inp) { #if (_WIN32_WINNT < 0x0600) const char* inet_ntop(int af, const void* src, char* dst, socklen_t size) { if (af != AF_INET) { - errno = EINVAL; - return 0; - } - const ui8* ia = (ui8*)src; - if (snprintf(dst, size, "%u.%u.%u.%u", ia[0], ia[1], ia[2], ia[3]) >= (int)size) { - errno = ENOSPC; - return 0; - } - return dst; -} + errno = EINVAL; + return 0; + } + const ui8* ia = (ui8*)src; + if (snprintf(dst, size, "%u.%u.%u.%u", ia[0], ia[1], ia[2], ia[3]) >= (int)size) { + errno = ENOSPC; + return 0; + } + return dst; +} struct evpair { int event; @@ -242,13 +242,13 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept { bool GetRemoteAddr(SOCKET Socket, char* str, socklen_t size) { if (!size) { - return false; + return false; } TOpaqueAddr addr; if (getpeername(Socket, addr.MutableAddr(), addr.LenPtr()) != 0) { - return false; + return false; } try { @@ -263,8 +263,8 @@ bool GetRemoteAddr(SOCKET Socket, char* str, socklen_t size) { } return false; -} - +} + void SetSocketTimeout(SOCKET s, long timeout) { SetSocketTimeout(s, timeout, 0); } diff --git a/util/string/printf_ut.cpp b/util/string/printf_ut.cpp index 76eea7023f..2b2f980b70 100644 --- a/util/string/printf_ut.cpp +++ b/util/string/printf_ut.cpp @@ -1,7 +1,7 @@ #include "printf.h" #include <library/cpp/testing/unittest/registar.h> - + Y_UNIT_TEST_SUITE(TStringPrintf) { Y_UNIT_TEST(TestSprintf) { TString s; diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp index be8ba0d89c..d1029d1498 100644 --- a/util/string/strip_ut.cpp +++ b/util/string/strip_ut.cpp @@ -1,7 +1,7 @@ #include "strip.h" #include <library/cpp/testing/unittest/registar.h> - + #include <util/charset/wide.h> Y_UNIT_TEST_SUITE(TStripStringTest) { @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { UNIT_ASSERT_EQUAL(StripStringLeft(inputStrBuf), test.StripLeftRes); UNIT_ASSERT_EQUAL(StripStringRight(inputStrBuf), test.StripRightRes); }; - } + } Y_UNIT_TEST(TestCustomStrip) { struct TTest { @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { #ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.c_str() == s2.c_str()); // Collapse() does not change the string at all #endif - } + } Y_UNIT_TEST(TestCollapseText) { TString abs1("Very long description string written in unknown language."); diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp index b651dab193..21eccef779 100644 --- a/util/string/subst_ut.cpp +++ b/util/string/subst_ut.cpp @@ -3,7 +3,7 @@ #include <string> #include <library/cpp/testing/unittest/registar.h> - + Y_UNIT_TEST_SUITE(TStringSubst) { static const size_t MIN_FROM_CTX = 4; static const TVector<TString> ALL_FROM{TString("F"), TString("FF")}; diff --git a/util/string/type_ut.cpp b/util/string/type_ut.cpp index 6b310146c9..03e7af62bd 100644 --- a/util/string/type_ut.cpp +++ b/util/string/type_ut.cpp @@ -1,7 +1,7 @@ #include "type.h" #include <library/cpp/testing/unittest/registar.h> - + #include <util/charset/wide.h> Y_UNIT_TEST_SUITE(TStringClassify) { diff --git a/util/string/util_ut.cpp b/util/string/util_ut.cpp index 6a214a2761..18a2d8e195 100644 --- a/util/string/util_ut.cpp +++ b/util/string/util_ut.cpp @@ -1,14 +1,14 @@ #include "util.h" #include <library/cpp/testing/unittest/registar.h> - + class TStrUtilTest: public TTestBase { UNIT_TEST_SUITE(TStrUtilTest); UNIT_TEST(TestSpn); UNIT_TEST(TestRemoveAll); UNIT_TEST_SUITE_END(); -public: +public: void TestSpn() { str_spn rul("a-z", true); char s[] = "!@#$ab%^&c+-"; @@ -41,6 +41,6 @@ public: UNIT_ASSERT_EQUAL(t->Result, str); } } -}; - +}; + UNIT_TEST_SUITE_REGISTRATION(TStrUtilTest); diff --git a/util/system/condvar.cpp b/util/system/condvar.cpp index 5519bf821a..62f3d22356 100644 --- a/util/system/condvar.cpp +++ b/util/system/condvar.cpp @@ -15,8 +15,8 @@ #include <sys/time.h> #include <pthread.h> #include <cerrno> -#endif - +#endif + namespace { class TCondVarImpl { using TLock = TAdaptiveLock; @@ -85,17 +85,17 @@ public: ythrow yexception() << "can not create condvar(" << LastSystemErrorText() << ")"; } } - + inline ~TImpl() { int ret = pthread_cond_destroy(&Cond_); Y_VERIFY(ret == 0, "pthread_cond_destroy failed: %s", LastSystemErrorText(ret)); } - + inline void Signal() noexcept { int ret = pthread_cond_signal(&Cond_); Y_VERIFY(ret == 0, "pthread_cond_signal failed: %s", LastSystemErrorText(ret)); } - + inline bool WaitD(TMutex& lock, TInstant deadLine) noexcept { if (deadLine == TInstant::Max()) { int ret = pthread_cond_wait(&Cond_, (pthread_mutex_t*)lock.Handle()); @@ -116,7 +116,7 @@ public: return ret == 0; } } - + inline void BroadCast() noexcept { int ret = pthread_cond_broadcast(&Cond_); Y_VERIFY(ret == 0, "pthread_cond_broadcast failed: %s", LastSystemErrorText(ret)); @@ -126,22 +126,22 @@ private: pthread_cond_t Cond_; }; #endif - + TCondVar::TCondVar() : Impl_(new TImpl) { -} - +} + TCondVar::~TCondVar() = default; - + void TCondVar::BroadCast() noexcept { Impl_->BroadCast(); } void TCondVar::Signal() noexcept { Impl_->Signal(); -} - +} + bool TCondVar::WaitD(TMutex& mutex, TInstant deadLine) noexcept { return Impl_->WaitD(mutex, deadLine); -} +} diff --git a/util/system/condvar.h b/util/system/condvar.h index aae33b2e50..569162717c 100644 --- a/util/system/condvar.h +++ b/util/system/condvar.h @@ -1,5 +1,5 @@ #pragma once - + #include "mutex.h" #include <util/generic/ptr.h> @@ -12,10 +12,10 @@ class TCondVar { public: TCondVar(); ~TCondVar(); - + void BroadCast() noexcept; void Signal() noexcept; - + /* * returns false if failed by timeout */ diff --git a/util/system/defaults.h b/util/system/defaults.h index 84c4580b02..dcd7abea38 100644 --- a/util/system/defaults.h +++ b/util/system/defaults.h @@ -1,7 +1,7 @@ #pragma once - + #include "platform.h" - + #if defined _unix_ #define LOCSLASH_C '/' #define LOCSLASH_S "/" @@ -58,12 +58,12 @@ #if defined(__GNUC__) #define alias_hack __attribute__((__may_alias__)) -#endif - -#ifndef alias_hack +#endif + +#ifndef alias_hack #define alias_hack -#endif - +#endif + #include "types.h" #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) @@ -80,7 +80,7 @@ #elif defined(_sun_) #include <alloca.h> #endif - + #ifdef NDEBUG #define Y_IF_DEBUG(X) #ifdef __cplusplus diff --git a/util/system/rwlock.cpp b/util/system/rwlock.cpp index 66b47e2a7e..bb3dcbf188 100644 --- a/util/system/rwlock.cpp +++ b/util/system/rwlock.cpp @@ -1,7 +1,7 @@ -#include "rwlock.h" +#include "rwlock.h" #include "mutex.h" #include "condvar.h" - + #include <util/generic/yexception.h> #if defined(_unix_) @@ -39,7 +39,7 @@ TRWMutex::TImpl::TImpl() , BlockedWriters_(0) { } - + TRWMutex::TImpl::~TImpl() { Y_VERIFY(State_ == 0, "failure, State_ != 0"); Y_VERIFY(BlockedWriters_ == 0, "failure, BlockedWriters_ != 0"); @@ -52,11 +52,11 @@ void TRWMutex::TImpl::AcquireRead() noexcept { } ++State_; - } + } ReadCond_.Signal(); } - + bool TRWMutex::TImpl::TryAcquireRead() noexcept { with_lock (Lock_) { if (BlockedWriters_ || State_ < 0) { @@ -128,18 +128,18 @@ void TRWMutex::TImpl::Release() noexcept { } else if (BlockedWriters_) { Lock_.Release(); WriteCond_.Signal(); - } + } } else { State_ = 0; if (BlockedWriters_) { Lock_.Release(); WriteCond_.Signal(); - } else { + } else { Lock_.Release(); ReadCond_.Signal(); - } - } + } + } } #else /* POSIX threads */ @@ -212,7 +212,7 @@ void TRWMutex::TImpl::Release() noexcept { Y_VERIFY(result == 0, "rwlock unlock failed (%s)", LastSystemErrorText(result)); } -#endif +#endif TRWMutex::TRWMutex() : Impl_(new TImpl()) diff --git a/util/system/rwlock.h b/util/system/rwlock.h index c4b28b06a5..0bb9b3fe1c 100644 --- a/util/system/rwlock.h +++ b/util/system/rwlock.h @@ -1,25 +1,25 @@ #pragma once - + #include "guard.h" #include "defaults.h" - + #include <util/generic/ptr.h> class TRWMutex { public: TRWMutex(); ~TRWMutex(); - + void AcquireRead() noexcept; bool TryAcquireRead() noexcept; void ReleaseRead() noexcept; - + void AcquireWrite() noexcept; bool TryAcquireWrite() noexcept; void ReleaseWrite() noexcept; void Release() noexcept; - + private: class TImpl; THolder<TImpl> Impl_; @@ -34,8 +34,8 @@ struct TReadGuardOps { static inline void Release(T* t) noexcept { t->ReleaseRead(); } -}; - +}; + template <class T> struct TTryReadGuardOps: public TReadGuardOps<T> { static inline bool TryAcquire(T* t) noexcept { @@ -52,8 +52,8 @@ struct TWriteGuardOps { static inline void Release(T* t) noexcept { t->ReleaseWrite(); } -}; - +}; + template <class T> struct TTryWriteGuardOps: public TWriteGuardOps<T> { static inline bool TryAcquire(T* t) noexcept { diff --git a/util/system/sem.cpp b/util/system/sem.cpp index e291f1423c..4a93b903b5 100644 --- a/util/system/sem.cpp +++ b/util/system/sem.cpp @@ -6,8 +6,8 @@ #include <alloca.h> #endif -#include <cerrno> -#include <cstring> +#include <cerrno> +#include <cstring> #ifdef _win_ #include "winint.h" diff --git a/util/system/tls.cpp b/util/system/tls.cpp index 5cef5ed235..c2f1a04a14 100644 --- a/util/system/tls.cpp +++ b/util/system/tls.cpp @@ -7,7 +7,7 @@ #include <util/generic/intrlist.h> #include <util/generic/singleton.h> #include <util/generic/vector.h> - + #if defined(_unix_) #include <pthread.h> #endif diff --git a/util/thread/pool.h b/util/thread/pool.h index 8a9ad12de6..d1ea3a67cb 100644 --- a/util/thread/pool.h +++ b/util/thread/pool.h @@ -381,7 +381,7 @@ inline void Delete(THolder<IThreadPool> q) { if (q.Get()) { q->Stop(); } -} +} /** * Creates and starts TThreadPool if threadsCount > 1, or TFakeThreadPool otherwise |