From 12b1b74d322f9933bb5d2ccbccd2566ee44cd3fc Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Mon, 7 Mar 2022 18:27:28 -0600 Subject: [PATCH] Trimming Fat Remove unused include statements or unused definitions. --- contrib/epee/include/file_io_utils.h | 3 -- contrib/epee/include/misc_language.h | 52 ------------------- contrib/epee/include/net/local_ip.h | 1 - .../include/storages/levin_abstract_invoke2.h | 48 ----------------- contrib/epee/src/connection_basic.cpp | 1 - contrib/epee/src/file_io_utils.cpp | 43 --------------- contrib/epee/src/network_throttle-detail.cpp | 1 - .../cryptonote_protocol_handler-base.cpp | 1 - src/p2p/net_node.inl | 1 - 9 files changed, 151 deletions(-) diff --git a/contrib/epee/include/file_io_utils.h b/contrib/epee/include/file_io_utils.h index 84dc79266..da05520c1 100644 --- a/contrib/epee/include/file_io_utils.h +++ b/contrib/epee/include/file_io_utils.h @@ -36,10 +36,7 @@ namespace file_io_utils { bool is_file_exist(const std::string& path); bool save_string_to_file(const std::string& path_to_file, const std::string& str); - bool get_file_time(const std::string& path_to_file, time_t& ft); - bool set_file_time(const std::string& path_to_file, const time_t& ft); bool load_file_to_string(const std::string& path_to_file, std::string& target_str, size_t max_size = 1000000000); - bool append_string_to_file(const std::string& path_to_file, const std::string& str); bool get_file_size(const std::string& path_to_file, uint64_t &size); } } diff --git a/contrib/epee/include/misc_language.h b/contrib/epee/include/misc_language.h index 5ccfe6fcc..bf75da23f 100644 --- a/contrib/epee/include/misc_language.h +++ b/contrib/epee/include/misc_language.h @@ -30,47 +30,13 @@ #include #include -#include -#include #include namespace epee { -#define STD_TRY_BEGIN() try { - -#define STD_TRY_CATCH(where_, ret_val) \ - } \ - catch (const std::exception &e) \ - { \ - LOG_ERROR("EXCEPTION: " << where_ << ", mes: "<< e.what()); \ - return ret_val; \ - } \ - catch (...) \ - { \ - LOG_ERROR("EXCEPTION: " << where_ ); \ - return ret_val; \ - } - - - #define AUTO_VAL_INIT(v) boost::value_initialized() namespace misc_utils { - template - t_type get_max_t_val(t_type t) - { - return (std::numeric_limits::max)(); - } - - - template - t_iterator move_it_forward(t_iterator it, size_t count) - { - while(count--) - it++; - return it; - } - template t_iterator move_it_backward(t_iterator it, size_t count) { @@ -79,24 +45,6 @@ namespace misc_utils return it; } - - // TEMPLATE STRUCT less - template - struct less_as_pod - : public std::binary_function<_Ty, _Ty, bool> - { // functor for operator< - bool operator()(const _Ty& _Left, const _Ty& _Right) const - { // apply operator< to operands - return memcmp(&_Left, &_Right, sizeof(_Left)) < 0; - } - }; - - template - bool is_less_as_pod(const _Ty& _Left, const _Ty& _Right) - { // apply operator< to operands - return memcmp(&_Left, &_Right, sizeof(_Left)) < 0; - } - bool sleep_no_w(long ms ); template diff --git a/contrib/epee/include/net/local_ip.h b/contrib/epee/include/net/local_ip.h index 1eeab2dc5..1c501d24b 100644 --- a/contrib/epee/include/net/local_ip.h +++ b/contrib/epee/include/net/local_ip.h @@ -27,7 +27,6 @@ #pragma once -#include #include "int-util.h" // IP addresses are kept in network byte order diff --git a/contrib/epee/include/storages/levin_abstract_invoke2.h b/contrib/epee/include/storages/levin_abstract_invoke2.h index 383d67cc2..7fd786a53 100644 --- a/contrib/epee/include/storages/levin_abstract_invoke2.h +++ b/contrib/epee/include/storages/levin_abstract_invoke2.h @@ -56,54 +56,6 @@ namespace epee { namespace net_utils { -#if 0 - template - bool invoke_remote_command2(int command, const t_arg& out_struct, t_result& result_struct, t_transport& transport) - { - if(!transport.is_connected()) - return false; - - serialization::portable_storage stg; - out_struct.store(stg); - std::string buff_to_send, buff_to_recv; - stg.store_to_binary(buff_to_send); - - int res = transport.invoke(command, buff_to_send, buff_to_recv); - if( res <=0 ) - { - MERROR("Failed to invoke command " << command << " return code " << res); - return false; - } - serialization::portable_storage stg_ret; - if(!stg_ret.load_from_binary(buff_to_recv, &default_levin_limits)) - { - LOG_ERROR("Failed to load_from_binary on command " << command); - return false; - } - return result_struct.load(stg_ret); - } - - template - bool notify_remote_command2(int command, const t_arg& out_struct, t_transport& transport) - { - if(!transport.is_connected()) - return false; - - serialization::portable_storage stg; - out_struct.store(&stg); - std::string buff_to_send; - stg.store_to_binary(buff_to_send); - - int res = transport.notify(command, buff_to_send); - if(res <=0 ) - { - LOG_ERROR("Failed to notify command " << command << " return code " << res); - return false; - } - return true; - } -#endif - template bool invoke_remote_command2(const epee::net_utils::connection_context_base context, int command, const t_arg& out_struct, t_result& result_struct, t_transport& transport) { diff --git a/contrib/epee/src/connection_basic.cpp b/contrib/epee/src/connection_basic.cpp index 85ff55587..b0a30f47f 100644 --- a/contrib/epee/src/connection_basic.cpp +++ b/contrib/epee/src/connection_basic.cpp @@ -39,7 +39,6 @@ #include #include #include "misc_language.h" -#include "pragma_comp_defs.h" #include #include diff --git a/contrib/epee/src/file_io_utils.cpp b/contrib/epee/src/file_io_utils.cpp index 5072adcbc..a8348431c 100644 --- a/contrib/epee/src/file_io_utils.cpp +++ b/contrib/epee/src/file_io_utils.cpp @@ -102,29 +102,6 @@ namespace file_io_utils } - bool get_file_time(const std::string& path_to_file, time_t& ft) - { - boost::system::error_code ec; - ft = boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ec); - if(!ec) - return true; - else - return false; - } - - - bool set_file_time(const std::string& path_to_file, const time_t& ft) - { - boost::system::error_code ec; - boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ft, ec); - if(!ec) - return true; - else - return false; - } - - - bool load_file_to_string(const std::string& path_to_file, std::string& target_str, size_t max_size) { #ifdef WIN32 @@ -174,26 +151,6 @@ namespace file_io_utils } - bool append_string_to_file(const std::string& path_to_file, const std::string& str) - { - // No special Windows implementation because so far not used in Monero code - try - { - std::ofstream fstream; - fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit); - fstream.open(path_to_file.c_str(), std::ios_base::binary | std::ios_base::out | std::ios_base::app); - fstream << str; - fstream.close(); - return true; - } - - catch(...) - { - return false; - } - } - - bool get_file_size(const std::string& path_to_file, uint64_t &size) { #ifdef WIN32 diff --git a/contrib/epee/src/network_throttle-detail.cpp b/contrib/epee/src/network_throttle-detail.cpp index 0374a449c..978572120 100644 --- a/contrib/epee/src/network_throttle-detail.cpp +++ b/contrib/epee/src/network_throttle-detail.cpp @@ -46,7 +46,6 @@ #include "misc_log_ex.h" #include #include "misc_language.h" -#include "pragma_comp_defs.h" #include #include #include diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp b/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp index 4c21de7a5..92ee08054 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp +++ b/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp @@ -43,7 +43,6 @@ #include #include #include "misc_language.h" -#include "pragma_comp_defs.h" #include diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 5c61ede3f..a3bc3bf24 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -55,7 +55,6 @@ #include "math_helper.h" #include "misc_log_ex.h" #include "p2p_protocol_defs.h" -#include "net/local_ip.h" #include "crypto/crypto.h" #include "storages/levin_abstract_invoke2.h" #include "cryptonote_core/cryptonote_core.h"