From 1874a917b0130c546ad1e32299dc1014a500d000 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Fri, 13 Jan 2017 08:44:08 -0500 Subject: [PATCH] added std:: prefix, end of file cleanup, formatting, consts --- include/libtorrent/aux_/merkle.hpp | 1 - include/libtorrent/aux_/non_owning_handle.hpp | 1 - include/libtorrent/aux_/session_impl.hpp | 2 +- include/libtorrent/aux_/session_interface.hpp | 9 +++------ .../libtorrent/aux_/win_crypto_provider.hpp | 19 +++++++++---------- include/libtorrent/aux_/win_util.hpp | 1 - include/libtorrent/lazy_entry.hpp | 3 +-- include/libtorrent/link.hpp | 1 - include/libtorrent/packet_buffer.hpp | 1 - include/libtorrent/sha512.hpp | 4 ++-- include/libtorrent/span.hpp | 18 +++++++++--------- include/libtorrent/stat_cache.hpp | 1 - include/libtorrent/units.hpp | 1 - include/libtorrent/utp_socket_manager.hpp | 2 +- include/libtorrent/utp_stream.hpp | 4 ++-- src/allocator.cpp | 9 ++++----- src/chained_buffer.cpp | 6 +++--- src/hex.cpp | 1 - src/sha512.cpp | 6 +++--- 19 files changed, 38 insertions(+), 52 deletions(-) diff --git a/include/libtorrent/aux_/merkle.hpp b/include/libtorrent/aux_/merkle.hpp index 8e99c7efe..af73d3df1 100644 --- a/include/libtorrent/aux_/merkle.hpp +++ b/include/libtorrent/aux_/merkle.hpp @@ -45,4 +45,3 @@ namespace libtorrent } #endif - diff --git a/include/libtorrent/aux_/non_owning_handle.hpp b/include/libtorrent/aux_/non_owning_handle.hpp index a2061bbd5..3696792f4 100644 --- a/include/libtorrent/aux_/non_owning_handle.hpp +++ b/include/libtorrent/aux_/non_owning_handle.hpp @@ -47,4 +47,3 @@ namespace libtorrent { namespace aux { }} #endif - diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 388a7688b..40391c05e 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -499,7 +499,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE TORRENT_DEPRECATED void pop_alerts(); TORRENT_DEPRECATED alert const* pop_alert(); - TORRENT_DEPRECATED size_t set_alert_queue_size_limit(size_t queue_size_limit_); + TORRENT_DEPRECATED std::size_t set_alert_queue_size_limit(std::size_t queue_size_limit_); TORRENT_DEPRECATED int upload_rate_limit_depr() const; TORRENT_DEPRECATED int download_rate_limit_depr() const; TORRENT_DEPRECATED int local_upload_rate_limit() const; diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index e4484ebd2..c93a6a2ea 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -40,20 +40,17 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/time.hpp" #include "libtorrent/disk_buffer_holder.hpp" #include "libtorrent/error_code.hpp" +#include "libtorrent/socket.hpp" // for tcp::endpoint #include "libtorrent/aux_/vector.hpp" #include #include -#include "libtorrent/socket.hpp" // for tcp::endpoint - -#include "libtorrent/aux_/disable_warnings_push.hpp" - #ifdef TORRENT_USE_OPENSSL +#include "libtorrent/aux_/disable_warnings_push.hpp" #include -#endif - #include "libtorrent/aux_/disable_warnings_pop.hpp" +#endif namespace libtorrent { diff --git a/include/libtorrent/aux_/win_crypto_provider.hpp b/include/libtorrent/aux_/win_crypto_provider.hpp index 79935dfe0..015bc9f82 100644 --- a/include/libtorrent/aux_/win_crypto_provider.hpp +++ b/include/libtorrent/aux_/win_crypto_provider.hpp @@ -7,14 +7,14 @@ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - * Neither the name of the author nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -106,7 +106,7 @@ namespace libtorrent { namespace aux } } - void get_hash(char *digest, size_t digest_size) + void get_hash(char *digest, std::size_t digest_size) { DWORD size = DWORD(digest_size); if (CryptGetHashParam(m_hash, HP_HASHVAL @@ -162,4 +162,3 @@ namespace libtorrent { namespace aux } // namespace libtorrent #endif - diff --git a/include/libtorrent/aux_/win_util.hpp b/include/libtorrent/aux_/win_util.hpp index dcc3d7f1a..b6a953fd4 100644 --- a/include/libtorrent/aux_/win_util.hpp +++ b/include/libtorrent/aux_/win_util.hpp @@ -82,4 +82,3 @@ namespace libtorrent { namespace aux } // namespace libtorrent #endif - diff --git a/include/libtorrent/lazy_entry.hpp b/include/libtorrent/lazy_entry.hpp index 5c65fd3ee..82f1940a6 100644 --- a/include/libtorrent/lazy_entry.hpp +++ b/include/libtorrent/lazy_entry.hpp @@ -156,7 +156,7 @@ namespace libtorrent // start points to the first decimal digit // length is the number of digits - void construct_int(char const* start, int length) + void construct_int(char const* start, int const length) { TORRENT_ASSERT(m_type == none_t); m_type = int_t; @@ -412,4 +412,3 @@ namespace libtorrent #endif // TORRENT_NO_DEPRECATE #endif - diff --git a/include/libtorrent/link.hpp b/include/libtorrent/link.hpp index 6b9ea0fa8..e819027e1 100644 --- a/include/libtorrent/link.hpp +++ b/include/libtorrent/link.hpp @@ -76,4 +76,3 @@ namespace libtorrent } #endif - diff --git a/include/libtorrent/packet_buffer.hpp b/include/libtorrent/packet_buffer.hpp index 15726a0a5..8c684b99b 100644 --- a/include/libtorrent/packet_buffer.hpp +++ b/include/libtorrent/packet_buffer.hpp @@ -139,4 +139,3 @@ namespace libtorrent } #endif // TORRENT_PACKET_BUFFER_HPP_INCLUDED - diff --git a/include/libtorrent/sha512.hpp b/include/libtorrent/sha512.hpp index f48056c0a..39613f0db 100644 --- a/include/libtorrent/sha512.hpp +++ b/include/libtorrent/sha512.hpp @@ -10,13 +10,13 @@ namespace libtorrent struct sha512_ctx { std::uint64_t length, state[8]; - size_t curlen; + std::size_t curlen; std::uint8_t buf[128]; }; TORRENT_EXTRA_EXPORT int SHA512_init(sha512_ctx* context); TORRENT_EXTRA_EXPORT int SHA512_update(sha512_ctx* context - , std::uint8_t const* data, size_t len); + , std::uint8_t const* data, std::size_t len); TORRENT_EXTRA_EXPORT int SHA512_final(std::uint8_t* digest, sha512_ctx* context); } diff --git a/include/libtorrent/span.hpp b/include/libtorrent/span.hpp index 812a3ee9c..495331eb2 100644 --- a/include/libtorrent/span.hpp +++ b/include/libtorrent/span.hpp @@ -52,11 +52,11 @@ namespace libtorrent span(T& p) : m_ptr(&p), m_len(1) {} // NOLINT span(T* p, size_t const l) : m_ptr(p), m_len(l) {} // NOLINT - template + template span(std::array& arr) // NOLINT : m_ptr(arr.data()), m_len(arr.size()) {} - template + template span(U (&arr)[N]) // NOLINT : m_ptr(&arr[0]), m_len(N) {} @@ -65,7 +65,7 @@ namespace libtorrent span(Cont& c) // NOLINT : m_ptr(c.data()), m_len(c.size()) {} - size_t size() const { return m_len; } + std::size_t size() const { return m_len; } bool empty() const { return m_len == 0; } T* data() const { return m_ptr; } @@ -80,32 +80,32 @@ namespace libtorrent T& front() const { TORRENT_ASSERT(m_len > 0); return m_ptr[0]; } T& back() const { TORRENT_ASSERT(m_len > 0); return m_ptr[m_len - 1]; } - span first(size_t const n) const + span first(std::size_t const n) const { TORRENT_ASSERT(size() >= n); return { data(), n }; } - span last(size_t const n) const + span last(std::size_t const n) const { TORRENT_ASSERT(size() >= n); return { data() + size() - n, n }; } - span subspan(size_t const offset) const + span subspan(std::size_t const offset) const { TORRENT_ASSERT(size() >= offset); return { data() + offset, size() - offset }; } - span subspan(size_t const offset, size_t const count) const + span subspan(std::size_t const offset, std::size_t const count) const { TORRENT_ASSERT(size() >= offset); TORRENT_ASSERT(size() >= offset + count); return { data() + offset, count }; } - T& operator[](size_t const idx) + T& operator[](std::size_t const idx) { TORRENT_ASSERT(idx < m_len); return m_ptr[idx]; @@ -113,7 +113,7 @@ namespace libtorrent private: T* m_ptr; - size_t m_len; + std::size_t m_len; }; } diff --git a/include/libtorrent/stat_cache.hpp b/include/libtorrent/stat_cache.hpp index 7875681dc..4c8e8fb16 100644 --- a/include/libtorrent/stat_cache.hpp +++ b/include/libtorrent/stat_cache.hpp @@ -100,4 +100,3 @@ namespace libtorrent } #endif // TORRENT_STAT_CACHE_HPP - diff --git a/include/libtorrent/units.hpp b/include/libtorrent/units.hpp index 5c636c8a0..79b0b607a 100644 --- a/include/libtorrent/units.hpp +++ b/include/libtorrent/units.hpp @@ -152,4 +152,3 @@ namespace std { } #endif - diff --git a/include/libtorrent/utp_socket_manager.hpp b/include/libtorrent/utp_socket_manager.hpp index 9985e2b82..5265ac8b2 100644 --- a/include/libtorrent/utp_socket_manager.hpp +++ b/include/libtorrent/utp_socket_manager.hpp @@ -104,7 +104,7 @@ namespace libtorrent void defer_ack(utp_socket_impl* s); void subscribe_drained(utp_socket_impl* s); - void restrict_mtu(int mtu) + void restrict_mtu(int const mtu) { m_restrict_mtu[std::size_t(m_mtu_idx)] = mtu; m_mtu_idx = (m_mtu_idx + 1) % int(m_restrict_mtu.size()); diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index 7ed846502..673fd79ad 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -253,9 +253,9 @@ public: bool is_open() const { return m_open; } int read_buffer_size() const; - static void on_read(void* self, size_t bytes_transferred + static void on_read(void* self, std::size_t bytes_transferred , error_code const& ec, bool kill); - static void on_write(void* self, size_t bytes_transferred + static void on_write(void* self, std::size_t bytes_transferred , error_code const& ec, bool kill); static void on_connect(void* self, error_code const& ec, bool kill); static void on_close_reason(void* self, std::uint16_t reason); diff --git a/src/allocator.cpp b/src/allocator.cpp index f0fef8b6f..7445c3fc4 100644 --- a/src/allocator.cpp +++ b/src/allocator.cpp @@ -107,7 +107,7 @@ namespace libtorrent TORRENT_ASSERT(int(bytes) >= page_size()); #ifdef TORRENT_DEBUG_BUFFERS const int page = page_size(); - const int num_pages = (bytes + (page-1)) / page + 2; + const int num_pages = (bytes + (page - 1)) / page + 2; const int orig_bytes = bytes; bytes = num_pages * page; #endif @@ -122,10 +122,10 @@ namespace libtorrent ret = _aligned_malloc(bytes, page_size()); #elif defined TORRENT_BEOS area_id id = create_area("", &ret, B_ANY_ADDRESS - , (bytes + page_size() - 1) & (page_size()-1), B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); + , (bytes + page_size() - 1) & (page_size() - 1), B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); if (id < B_OK) return nullptr; #else - ret = valloc(size_t(bytes)); + ret = valloc(std::size_t(bytes)); #endif if (ret == nullptr) return nullptr; @@ -141,7 +141,7 @@ namespace libtorrent #define PROT_READ PAGE_READONLY #endif mprotect(ret, std::size_t(page), PROT_READ); - mprotect(static_cast(ret) + (num_pages-1) * page, std::size_t(page), PROT_READ); + mprotect(static_cast(ret) + (num_pages - 1) * page, std::size_t(page), PROT_READ); #ifdef TORRENT_WINDOWS #undef mprotect @@ -208,4 +208,3 @@ namespace libtorrent #endif } - diff --git a/src/chained_buffer.cpp b/src/chained_buffer.cpp index 08ddbd399..124079065 100644 --- a/src/chained_buffer.cpp +++ b/src/chained_buffer.cpp @@ -84,7 +84,7 @@ namespace libtorrent // tries to copy the given buffer to the end of the // last chained buffer. If there's not enough room // it returns false - char* chained_buffer::append(char const* buf, int s) + char* chained_buffer::append(char const* buf, int const s) { TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(!m_destructed); @@ -97,7 +97,7 @@ namespace libtorrent // tries to allocate memory from the end // of the last buffer. If there isn't // enough room, returns 0 - char* chained_buffer::allocate_appendix(int s) + char* chained_buffer::allocate_appendix(int const s) { TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(!m_destructed); @@ -112,7 +112,7 @@ namespace libtorrent return insert; } - std::vector const& chained_buffer::build_iovec(int to_send) + std::vector const& chained_buffer::build_iovec(int const to_send) { TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(!m_destructed); diff --git a/src/hex.cpp b/src/hex.cpp index a39fbe07c..c950c7cba 100644 --- a/src/hex.cpp +++ b/src/hex.cpp @@ -103,4 +103,3 @@ namespace libtorrent } // aux namespace } - diff --git a/src/sha512.cpp b/src/sha512.cpp index dc5b30ace..0336cbfd1 100644 --- a/src/sha512.cpp +++ b/src/sha512.cpp @@ -184,10 +184,10 @@ int SHA512_init(sha512_ctx* md) { @param inlen The length of the data (octets) @return 0 if successful */ -int SHA512_update(sha512_ctx* md, std::uint8_t const* in, size_t inlen) +int SHA512_update(sha512_ctx* md, std::uint8_t const* in, std::size_t inlen) { - size_t n; - size_t i; + std::size_t n; + std::size_t i; int err; if (md == NULL) return 1; if (in == NULL) return 1;