From 897a6face2c4f3cec1b7e1d6360a54dc0420c1f9 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 29 May 2025 17:06:35 -0700 Subject: [PATCH] clang-tidy: use default member init Signed-off-by: Rosen Penev --- src/control.cc | 21 ++++++++------------- src/control.h | 6 +++--- src/core/curl_get.cc | 4 +--- src/core/curl_get.h | 4 ++-- src/core/dht_manager.h | 5 ++--- src/core/download.cc | 6 +----- src/core/download.h | 6 +++--- src/core/download_factory.cc | 12 +----------- src/core/download_factory.h | 18 +++++++++--------- src/core/download_list.h | 2 +- src/core/http_queue.h | 2 +- src/core/manager.cc | 1 - src/core/manager.h | 2 +- src/core/range_map.h | 2 +- src/core/view.h | 2 +- src/core/view_manager.h | 2 +- src/display/attributes.h | 2 +- src/display/frame.cc | 9 --------- src/display/frame.h | 14 ++++++-------- src/display/text_element.h | 4 ++-- src/display/text_element_list.h | 5 ++--- src/display/window_download_list.cc | 3 +-- src/display/window_download_list.h | 2 +- src/display/window_input.h | 8 +++----- src/display/window_log_complete.cc | 3 +-- src/display/window_statusbar.h | 5 ++--- src/display/window_string_list.cc | 3 +-- src/display/window_text.cc | 8 +++----- src/display/window_text.h | 4 ++-- src/input/bindings.h | 4 ++-- src/input/manager.h | 6 ++---- src/input/path_input.cc | 4 ---- src/input/path_input.h | 5 ++--- src/input/text_input.h | 5 ++--- src/rpc/command_impl.h | 2 +- src/rpc/command_map.h | 6 ++---- src/rpc/command_scheduler.h | 2 +- src/rpc/command_scheduler_item.h | 4 ++-- src/rpc/exec_file.h | 4 +--- src/rpc/rpc_manager.h | 2 +- src/rpc/scgi.h | 3 +-- src/rpc/xmlrpc.h | 10 ++++------ src/ui/download.cc | 4 +--- src/ui/download.h | 4 ++-- src/ui/download_list.cc | 4 +--- src/ui/download_list.h | 2 +- src/ui/element_base.h | 7 +++---- src/ui/element_chunks_seen.cc | 4 +--- src/ui/element_chunks_seen.h | 5 ++--- src/ui/element_download_list.cc | 5 +---- src/ui/element_download_list.h | 4 ++-- src/ui/element_file_list.cc | 10 ++-------- src/ui/element_file_list.h | 10 +++++----- src/ui/element_log_complete.cc | 3 +-- src/ui/element_log_complete.h | 2 +- src/ui/element_peer_list.cc | 3 +-- src/ui/element_peer_list.h | 2 +- src/ui/element_string_list.cc | 4 ---- src/ui/element_string_list.h | 4 +--- src/ui/element_text.cc | 4 +--- src/ui/element_text.h | 4 ++-- src/ui/element_tracker_list.cc | 4 +--- src/ui/element_tracker_list.h | 4 ++-- src/ui/element_transfer_list.cc | 4 +--- src/ui/element_transfer_list.h | 5 ++--- src/utils/directory.h | 2 +- src/utils/lockfile.h | 4 +--- 67 files changed, 119 insertions(+), 211 deletions(-) diff --git a/src/control.cc b/src/control.cc index 9242efd3..2d39c08d 100644 --- a/src/control.cc +++ b/src/control.cc @@ -29,19 +29,14 @@ #include "control.h" Control::Control() : - m_ui(new ui::Root()), - m_display(new display::Manager()), - m_input(new input::Manager()), - m_inputStdin(new input::InputEvent(STDIN_FILENO)), - - m_commandScheduler(new rpc::CommandScheduler()), - m_objectStorage(new rpc::object_storage()), - m_lua_engine(new rpc::LuaEngine()), - m_directory_events(new torrent::directory_events()), - - m_tick(0), - m_shutdownReceived(false), - m_shutdownQuick(false) { + m_ui(new ui::Root()), + m_display(new display::Manager()), + m_input(new input::Manager()), + m_inputStdin(new input::InputEvent(STDIN_FILENO)), + m_commandScheduler(new rpc::CommandScheduler()), + m_objectStorage(new rpc::object_storage()), + m_lua_engine(new rpc::LuaEngine()), + m_directory_events(new torrent::directory_events()) { m_core = new core::Manager(); m_viewManager = new core::ViewManager(); diff --git a/src/control.h b/src/control.h index 7acd407f..ee56307c 100644 --- a/src/control.h +++ b/src/control.h @@ -94,15 +94,15 @@ private: rpc::LuaEngine* m_lua_engine; torrent::directory_events* m_directory_events; - uint64_t m_tick; + uint64_t m_tick{}; mode_t m_umask; std::string m_workingDirectory; torrent::utils::SchedulerEntry m_task_shutdown; - std::atomic m_shutdownReceived; - std::atomic m_shutdownQuick; + std::atomic m_shutdownReceived{}; + std::atomic m_shutdownQuick{}; }; #endif diff --git a/src/core/curl_get.cc b/src/core/curl_get.cc index 82ed81f4..6c2c4af4 100644 --- a/src/core/curl_get.cc +++ b/src/core/curl_get.cc @@ -21,9 +21,7 @@ curl_get_receive_write(void* data, size_t size, size_t nmemb, void* handle) { } CurlGet::CurlGet(CurlStack* s) : - m_active(false), - m_handle(NULL), - m_stack(s) { + m_stack(s) { m_task_timeout.slot() = [this]() { receive_timeout(); }; } diff --git a/src/core/curl_get.h b/src/core/curl_get.h index fc300d9a..ed2b9bfb 100644 --- a/src/core/curl_get.h +++ b/src/core/curl_get.h @@ -40,12 +40,12 @@ private: void receive_timeout(); - bool m_active; + bool m_active{}; bool m_ipv6; torrent::utils::SchedulerEntry m_task_timeout; - CURL* m_handle; + CURL* m_handle{}; CurlStack* m_stack; }; diff --git a/src/core/dht_manager.h b/src/core/dht_manager.h index 824d5266..16772205 100644 --- a/src/core/dht_manager.h +++ b/src/core/dht_manager.h @@ -8,7 +8,6 @@ namespace core { class DhtManager { public: - DhtManager() : m_warned(false), m_start(dht_off) { } ~DhtManager(); void load_dht_cache(); @@ -46,9 +45,9 @@ private: torrent::utils::SchedulerEntry m_update_timeout; torrent::utils::SchedulerEntry m_stop_timeout; - bool m_warned; + bool m_warned{}; - int m_start; + int m_start{dht_off}; std::string m_throttleName; }; diff --git a/src/core/download.cc b/src/core/download.cc index 3d3e176d..7db1f96a 100644 --- a/src/core/download.cc +++ b/src/core/download.cc @@ -18,11 +18,7 @@ namespace core { Download::Download(download_type d) : - m_download(d), - m_hashFailed(false), - - m_resumeFlags(~uint32_t()), - m_group(0) { + m_download(d) { m_download.info()->signal_tracker_success().push_back(std::bind(&Download::receive_tracker_msg, this, "")); m_download.info()->signal_tracker_failed().push_back(std::bind(&Download::receive_tracker_msg, this, std::placeholders::_1)); diff --git a/src/core/download.h b/src/core/download.h index 8a52c851..d9da7257 100644 --- a/src/core/download.h +++ b/src/core/download.h @@ -100,10 +100,10 @@ private: // Store the FileList instance so we can use slots etc on it. download_type m_download; - bool m_hashFailed; + bool m_hashFailed{}; std::string m_message; - uint32_t m_resumeFlags; - unsigned int m_group; + uint32_t m_resumeFlags{~uint32_t{}}; + unsigned int m_group{}; }; inline bool diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index c8b50dd1..ee44c909 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -60,17 +60,7 @@ is_magnet_uri(const std::string& uri) { } DownloadFactory::DownloadFactory(Manager* m) : - m_manager(m), - m_stream(NULL), - m_object(NULL), - m_commited(false), - m_loaded(false), - - m_session(false), - m_start(false), - m_printLog(true), - m_isFile(false), - m_initLoad(false) { + m_manager(m) { m_task_load.slot() = std::bind(&DownloadFactory::receive_load, this); m_task_commit.slot() = std::bind(&DownloadFactory::receive_commit, this); diff --git a/src/core/download_factory.h b/src/core/download_factory.h index a770579c..f1ea2f8c 100644 --- a/src/core/download_factory.h +++ b/src/core/download_factory.h @@ -63,18 +63,18 @@ private: void initialize_rtorrent(Download* download, torrent::Object* rtorrent); Manager* m_manager; - std::iostream* m_stream; - torrent::Object* m_object; + std::iostream* m_stream{}; + torrent::Object* m_object{}; - bool m_commited; - bool m_loaded; + bool m_commited{}; + bool m_loaded{}; std::string m_uri; - bool m_session; - bool m_start; - bool m_printLog; - bool m_isFile; - bool m_initLoad; + bool m_session{}; + bool m_start{}; + bool m_printLog{true}; + bool m_isFile{}; + bool m_initLoad{}; command_list_type m_commands; torrent::Object::map_type m_variables; diff --git a/src/core/download_list.h b/src/core/download_list.h index 0e73d00c..40d24d83 100644 --- a/src/core/download_list.h +++ b/src/core/download_list.h @@ -39,7 +39,7 @@ public: using base_type::empty; using base_type::size; - DownloadList() { } + DownloadList() = default; void clear(); diff --git a/src/core/http_queue.h b/src/core/http_queue.h index 22c94fce..a39fffd4 100644 --- a/src/core/http_queue.h +++ b/src/core/http_queue.h @@ -29,7 +29,7 @@ public: using base_type::empty; using base_type::size; - HttpQueue() {} + HttpQueue() = default; ~HttpQueue() { clear(); } // Note that any slots connected to the CurlGet signals must be diff --git a/src/core/manager.cc b/src/core/manager.cc index 5035142d..d77ccf6a 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -50,7 +50,6 @@ Manager::push_log(const char* msg) { } Manager::Manager() : - m_hashingView(nullptr), m_log_important(torrent::log_open_log_buffer("important")), m_log_complete(torrent::log_open_log_buffer("complete")) { diff --git a/src/core/manager.h b/src/core/manager.h index ebbf5373..065e9c93 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -111,7 +111,7 @@ private: std::unique_ptr m_http_queue; std::unique_ptr m_http_stack; - View* m_hashingView; + View* m_hashingView{}; ThrottleMap m_throttles; AddressThrottleMap m_addressThrottles; diff --git a/src/core/range_map.h b/src/core/range_map.h index 38b9b42e..0a513ae6 100644 --- a/src/core/range_map.h +++ b/src/core/range_map.h @@ -57,7 +57,7 @@ class RangeMap : private std::map, Compare, //std::allocator_traits::template rebind_alloc>> public: - RangeMap() {} + RangeMap() = default; RangeMap(const Compare& c) : base_type(c) {} typedef typename base_type::iterator iterator; diff --git a/src/core/view.h b/src/core/view.h index ece48638..73b3dc0b 100644 --- a/src/core/view.h +++ b/src/core/view.h @@ -39,7 +39,7 @@ public: using base_type::size_type; - View() {} + View() = default; ~View(); void initialize(const std::string& name); diff --git a/src/core/view_manager.h b/src/core/view_manager.h index 7858b092..b70791c3 100644 --- a/src/core/view_manager.h +++ b/src/core/view_manager.h @@ -28,7 +28,7 @@ public: using base_type::empty; using base_type::size; - ViewManager() {} + ViewManager() = default; ~ViewManager() { clear(); } // Ffff... Just throwing together an interface, need to think some diff --git a/src/display/attributes.h b/src/display/attributes.h index 132de03b..5a170443 100644 --- a/src/display/attributes.h +++ b/src/display/attributes.h @@ -35,7 +35,7 @@ public: static const int color_invalid = ~int(); static const int color_default = 0; - Attributes() {} + Attributes() = default; Attributes(const char* pos, int attr, int col) : m_position(pos), m_attributes(attr), m_colors(col) {} Attributes(const char* pos, const Attributes& old) : diff --git a/src/display/frame.cc b/src/display/frame.cc index aa01d833..ab76e86b 100644 --- a/src/display/frame.cc +++ b/src/display/frame.cc @@ -47,15 +47,6 @@ namespace display { -Frame::Frame() : - m_type(TYPE_NONE), - - m_positionX(0), - m_positionY(0), - m_width(0), - m_height(0) { -} - bool Frame::is_width_dynamic() const { switch (m_type) { diff --git a/src/display/frame.h b/src/display/frame.h index 1e936224..c33c5b0c 100644 --- a/src/display/frame.h +++ b/src/display/frame.h @@ -56,7 +56,7 @@ public: }; struct bounds_type { - bounds_type() {} + bounds_type() = default; bounds_type(extent_type minW, extent_type minH, extent_type maxW, extent_type maxH) : minWidth(minW), minHeight(minH), maxWidth(maxW), maxHeight(maxH) {} @@ -74,8 +74,6 @@ public: static const size_type max_size = 5; - Frame(); - bool is_width_dynamic() const; bool is_height_dynamic() const; @@ -116,12 +114,12 @@ private: inline void balance_row(uint32_t x, uint32_t y, uint32_t width, uint32_t height); inline void balance_column(uint32_t x, uint32_t y, uint32_t width, uint32_t height); - Type m_type; + Type m_type{TYPE_NONE}; - uint32_t m_positionX; - uint32_t m_positionY; - uint32_t m_width; - uint32_t m_height; + uint32_t m_positionX{}; + uint32_t m_positionY{}; + uint32_t m_width{}; + uint32_t m_height{}; union { Window* m_window; diff --git a/src/display/text_element.h b/src/display/text_element.h index a24a479a..89cdbda2 100644 --- a/src/display/text_element.h +++ b/src/display/text_element.h @@ -51,8 +51,8 @@ public: static const extent_type extent_full = ~extent_type(); - TextElement() {} - virtual ~TextElement() {} + TextElement() = default; + virtual ~TextElement() = default; // The last element must point to a valid memory location into which // the caller must write a '\0' to terminate the c string. The diff --git a/src/display/text_element_list.h b/src/display/text_element_list.h index 29f7ce50..a5ea927a 100644 --- a/src/display/text_element_list.h +++ b/src/display/text_element_list.h @@ -61,7 +61,6 @@ public: using base_type::push_back; - TextElementList() : m_column(0), m_columnWidth(0) {} virtual ~TextElementList() { clear(); } void clear(); @@ -74,8 +73,8 @@ public: virtual extent_type max_length(); private: - unsigned int m_column; - extent_type* m_columnWidth; + unsigned int m_column{}; + extent_type* m_columnWidth{}; }; } diff --git a/src/display/window_download_list.cc b/src/display/window_download_list.cc index 6c6f67a1..71d0ef81 100644 --- a/src/display/window_download_list.cc +++ b/src/display/window_download_list.cc @@ -15,8 +15,7 @@ namespace display { WindowDownloadList::WindowDownloadList() : - Window(new Canvas, 0, 120, 1, extent_full, extent_full), - m_view(NULL) { + Window(new Canvas, 0, 120, 1, extent_full, extent_full) { } WindowDownloadList::~WindowDownloadList() { diff --git a/src/display/window_download_list.h b/src/display/window_download_list.h index 8133c4a0..207ffe9d 100644 --- a/src/display/window_download_list.h +++ b/src/display/window_download_list.h @@ -24,7 +24,7 @@ public: int page_size(); private: - core::View* m_view; + core::View* m_view{}; std::pair get_attr_color(core::View::iterator selected); signal_void_itr m_changed_itr; diff --git a/src/display/window_input.h b/src/display/window_input.h index ed228e84..dd8adf0a 100644 --- a/src/display/window_input.h +++ b/src/display/window_input.h @@ -50,9 +50,7 @@ namespace display { class WindowInput : public Window { public: WindowInput() : - Window(new Canvas, 0, 0, 1, extent_full, 1), - m_input(NULL), - m_focus(false) {} + Window(new Canvas, 0, 0, 1, extent_full, 1) {} input::TextInput* input() { return m_input; } void set_input(input::TextInput* input) { m_input = input; } @@ -66,10 +64,10 @@ public: virtual void redraw(); private: - input::TextInput* m_input; + input::TextInput* m_input{}; std::string m_title; - bool m_focus; + bool m_focus{}; }; } diff --git a/src/display/window_log_complete.cc b/src/display/window_log_complete.cc index 052b1292..d84b3d30 100644 --- a/src/display/window_log_complete.cc +++ b/src/display/window_log_complete.cc @@ -13,8 +13,7 @@ WindowLogComplete::WindowLogComplete(torrent::log_buffer* l) : m_log(l) { } -WindowLogComplete::~WindowLogComplete() { -} +WindowLogComplete::~WindowLogComplete() = default; WindowLogComplete::iterator WindowLogComplete::find_older() { diff --git a/src/display/window_statusbar.h b/src/display/window_statusbar.h index 6effcf9b..8d998d88 100644 --- a/src/display/window_statusbar.h +++ b/src/display/window_statusbar.h @@ -10,13 +10,12 @@ namespace display { class WindowStatusbar : public Window { public: WindowStatusbar() : - Window(new Canvas, 0, 0, 1, extent_full, extent_static), - m_lastTick(0) {} + Window(new Canvas, 0, 0, 1, extent_full, extent_static) {} virtual void redraw(); private: - uint64_t m_lastTick; + uint64_t m_lastTick{}; }; } diff --git a/src/display/window_string_list.cc b/src/display/window_string_list.cc index 15c78793..7090ffbe 100644 --- a/src/display/window_string_list.cc +++ b/src/display/window_string_list.cc @@ -10,8 +10,7 @@ WindowStringList::WindowStringList() : Window(new Canvas, 0, 0, 0, extent_full, extent_full) { } -WindowStringList::~WindowStringList() { -} +WindowStringList::~WindowStringList() = default; void WindowStringList::redraw() { diff --git a/src/display/window_text.cc b/src/display/window_text.cc index 3ed832b5..14eec397 100644 --- a/src/display/window_text.cc +++ b/src/display/window_text.cc @@ -9,11 +9,9 @@ namespace display { WindowText::WindowText(rpc::target_type target, extent_type margin) : - Window(new Canvas, 0, 0, 0, extent_static, extent_static), - m_target(target), - m_errorHandler(NULL), - m_margin(margin), - m_interval(0) { + Window(new Canvas, 0, 0, 0, extent_static, extent_static), + m_target(target), + m_margin(margin) { } void diff --git a/src/display/window_text.h b/src/display/window_text.h index a999de8d..5cc14bc1 100644 --- a/src/display/window_text.h +++ b/src/display/window_text.h @@ -47,10 +47,10 @@ public: private: rpc::target_type m_target; - TextElement* m_errorHandler; + TextElement* m_errorHandler{}; extent_type m_margin; - uint32_t m_interval; + uint32_t m_interval{}; }; } diff --git a/src/input/bindings.h b/src/input/bindings.h index 8d53ab37..4d45280d 100644 --- a/src/input/bindings.h +++ b/src/input/bindings.h @@ -64,7 +64,7 @@ public: using base_type::operator[]; - Bindings() : m_enabled(true) {} + Bindings() = default; void enable() { m_enabled = true; } void disable() { m_enabled = false; } @@ -74,7 +74,7 @@ public: void ignore(int key) { (*this)[key] = slot_void(); } private: - bool m_enabled; + bool m_enabled{true}; }; } diff --git a/src/input/manager.h b/src/input/manager.h index b6f40b27..d1b7aabf 100644 --- a/src/input/manager.h +++ b/src/input/manager.h @@ -24,16 +24,14 @@ public: using Base::push_back; - Manager() : m_textInput(NULL) {} - void erase(Bindings* b); void pressed(int key); - void set_text_input(TextInput* input = NULL) { m_textInput = input; } + void set_text_input(TextInput* input = nullptr) { m_textInput = input; } private: - TextInput* m_textInput; + TextInput* m_textInput{}; }; } diff --git a/src/input/path_input.cc b/src/input/path_input.cc index 91ba37d4..9ae62866 100644 --- a/src/input/path_input.cc +++ b/src/input/path_input.cc @@ -49,10 +49,6 @@ namespace input { -PathInput::PathInput() : - m_showNext(false) { -} - bool PathInput::pressed(int key) { // Consider binding tab in m_bindings instead. diff --git a/src/input/path_input.h b/src/input/path_input.h index 11bbb824..21c3a7f9 100644 --- a/src/input/path_input.h +++ b/src/input/path_input.h @@ -55,8 +55,7 @@ public: typedef std::list signal_void; typedef std::list signal_itr_itr; - PathInput(); - virtual ~PathInput() {} + virtual ~PathInput() = default; signal_void& signal_show_next() { return m_signal_show_next; } signal_itr_itr& signal_show_range() { return m_signal_show_range; } @@ -69,7 +68,7 @@ private: size_type find_last_delim(); range_type find_incomplete(utils::Directory& d, const std::string& f); - bool m_showNext; + bool m_showNext{}; signal_void m_signal_show_next; signal_itr_itr m_signal_show_range; diff --git a/src/input/text_input.h b/src/input/text_input.h index f703e60e..734f4905 100644 --- a/src/input/text_input.h +++ b/src/input/text_input.h @@ -54,8 +54,7 @@ public: using Base::size_type; using Base::npos; - TextInput() : m_pos(0) {} - virtual ~TextInput() {} + virtual ~TextInput() = default; size_type get_pos() { return m_pos; } void set_pos(size_type pos) { m_pos = pos; } @@ -72,7 +71,7 @@ public: Bindings& bindings() { return m_bindings; } private: - size_type m_pos; + size_type m_pos{}; slot_void m_slot_dirty; diff --git a/src/rpc/command_impl.h b/src/rpc/command_impl.h index 91bb9508..30e1258c 100644 --- a/src/rpc/command_impl.h +++ b/src/rpc/command_impl.h @@ -68,7 +68,7 @@ command_base::pop_stack(stack_type* stack, torrent::Object* last_stack) { last_stack->~Object(); // To ensure we catch errors: - std::memset(last_stack, 0xAA, sizeof(torrent::Object)); + std::memset((void*)last_stack, 0xAA, sizeof(torrent::Object)); } } diff --git a/src/rpc/command_map.h b/src/rpc/command_map.h index 7c342193..fa76f477 100644 --- a/src/rpc/command_map.h +++ b/src/rpc/command_map.h @@ -20,9 +20,7 @@ struct command_map_data_type { command_map_data_type(int flags, const char* parm, const char* doc) : m_flags(flags), m_parm(parm), m_doc(doc) {} - command_map_data_type(const command_map_data_type& src) : - m_variable(src.m_variable), m_anySlot(src.m_anySlot), - m_flags(src.m_flags), m_parm(src.m_parm), m_doc(src.m_doc) {} + command_map_data_type(const command_map_data_type& src) = default; command_base m_variable; command_base::any_slot m_anySlot; @@ -59,7 +57,7 @@ public: static const int flag_file_target = 0x200; static const int flag_tracker_target = 0x400; - CommandMap() {} + CommandMap() = default; bool has(const std::string& key) const { return base_type::find(key) != base_type::end(); } diff --git a/src/rpc/command_scheduler.h b/src/rpc/command_scheduler.h index 2a4e3b95..1b654191 100644 --- a/src/rpc/command_scheduler.h +++ b/src/rpc/command_scheduler.h @@ -24,7 +24,7 @@ public: using base_type::begin; using base_type::end; - CommandScheduler() {} + CommandScheduler() = default; ~CommandScheduler(); void set_slot_error_message(SlotString s) { m_slotErrorMessage = s; } diff --git a/src/rpc/command_scheduler_item.h b/src/rpc/command_scheduler_item.h index 6cdd24ff..e70e55bf 100644 --- a/src/rpc/command_scheduler_item.h +++ b/src/rpc/command_scheduler_item.h @@ -13,7 +13,7 @@ class CommandSchedulerItem { public: typedef std::function slot_void; - CommandSchedulerItem(const std::string& key) : m_key(key), m_interval(0) {} + CommandSchedulerItem(const std::string& key) : m_key(key) {} ~CommandSchedulerItem(); bool is_queued() const { return m_task.is_scheduled(); } @@ -40,7 +40,7 @@ private: std::string m_key; torrent::Object m_command; - uint32_t m_interval; + uint32_t m_interval{}; std::chrono::microseconds m_time_scheduled; torrent::utils::SchedulerEntry m_task; diff --git a/src/rpc/exec_file.h b/src/rpc/exec_file.h index 6b3e0fd2..dc0aa160 100644 --- a/src/rpc/exec_file.h +++ b/src/rpc/exec_file.h @@ -15,8 +15,6 @@ public: static constexpr int flag_capture = 0x4; static constexpr int flag_background = 0x8; - ExecFile() : m_log_fd(-1) {} - int log_fd() const { return m_log_fd; } void set_log_fd(int fd) { m_log_fd = fd; } @@ -24,7 +22,7 @@ public: torrent::Object execute_object(const torrent::Object& rawArgs, int flags); private: - int m_log_fd; + int m_log_fd{-1}; std::string m_capture; }; diff --git a/src/rpc/rpc_manager.h b/src/rpc/rpc_manager.h index a6474315..36061583 100644 --- a/src/rpc/rpc_manager.h +++ b/src/rpc/rpc_manager.h @@ -24,7 +24,7 @@ class rpc_error : public torrent::base_error { public: rpc_error(int type, std::string msg) : m_type(type), m_msg(msg) {} - virtual ~rpc_error() throw() {} + virtual ~rpc_error() throw() = default; virtual int type() const throw() { return m_type; } virtual const char* what() const throw() { return m_msg.c_str(); } diff --git a/src/rpc/scgi.h b/src/rpc/scgi.h index afb0340e..0e97c983 100644 --- a/src/rpc/scgi.h +++ b/src/rpc/scgi.h @@ -17,7 +17,6 @@ class SCgi : public torrent::Event { public: static const int max_tasks = 100; - SCgi() : m_logFd(-1) {} ~SCgi() override; const char* type_name() const override { return "scgi"; } @@ -43,7 +42,7 @@ private: void open(void* sa, unsigned int length); std::string m_path; - int m_logFd; + int m_logFd{-1}; SCgiTask m_task[max_tasks]; }; diff --git a/src/rpc/xmlrpc.h b/src/rpc/xmlrpc.h index 825cc485..d79ed703 100644 --- a/src/rpc/xmlrpc.h +++ b/src/rpc/xmlrpc.h @@ -38,8 +38,6 @@ public: static void object_to_target(const torrent::Object& obj, int callFlags, rpc::target_type* target); - XmlRpc() : m_env(NULL), m_registry(NULL), m_dialect(dialect_i8), m_sizeLimit(SCgiTask::max_content_size) {} - bool is_valid() const; void initialize(); @@ -67,14 +65,14 @@ private: slot_peer m_slotFindPeer; // Only used by xmlrpc-c - void* m_env; - void* m_registry; + void* m_env{}; + void* m_registry{}; - int m_dialect; + int m_dialect{dialect_i8}; // Only used by tinyxml2 bool m_isValid; - uint64_t m_sizeLimit; + uint64_t m_sizeLimit{SCgiTask::max_content_size}; }; diff --git a/src/ui/download.cc b/src/ui/download.cc index 19fd04c5..d32d02b2 100644 --- a/src/ui/download.cc +++ b/src/ui/download.cc @@ -34,9 +34,7 @@ namespace ui { Download::Download(core::Download* d) : - m_download(d), - m_state(DISPLAY_MAX_SIZE), - m_focusDisplay(false) { + m_download(d) { m_windowDownloadStatus = new WDownloadStatus(d); m_windowDownloadStatus->set_bottom(true); diff --git a/src/ui/download.h b/src/ui/download.h index d4ba0a7f..82e8f155 100644 --- a/src/ui/download.h +++ b/src/ui/download.h @@ -110,10 +110,10 @@ private: core::Download* m_download; - Display m_state; + Display m_state{DISPLAY_MAX_SIZE}; ElementBase* m_uiArray[DISPLAY_MAX_SIZE]; - bool m_focusDisplay; + bool m_focusDisplay{}; WDownloadStatus* m_windowDownloadStatus; }; diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index 9ebe9bba..662764fa 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -33,9 +33,7 @@ namespace ui { -DownloadList::DownloadList() : - m_state(DISPLAY_MAX_SIZE) { - +DownloadList::DownloadList() { m_uiArray[DISPLAY_DOWNLOAD] = NULL; m_uiArray[DISPLAY_DOWNLOAD_LIST] = new ElementDownloadList(); m_uiArray[DISPLAY_LOG] = new ElementLogComplete(control->core()->log_complete()); diff --git a/src/ui/download_list.h b/src/ui/download_list.h index 791ee616..0f27d5db 100644 --- a/src/ui/download_list.h +++ b/src/ui/download_list.h @@ -116,7 +116,7 @@ private: void setup_keys(); void setup_input(); - Display m_state; + Display m_state{DISPLAY_MAX_SIZE}; ElementBase* m_uiArray[DISPLAY_MAX_SIZE]; WLog* m_windowLog; diff --git a/src/ui/element_base.h b/src/ui/element_base.h index 27ce98c3..3757b4e0 100644 --- a/src/ui/element_base.h +++ b/src/ui/element_base.h @@ -50,8 +50,7 @@ class ElementBase { public: typedef std::function slot_type; - ElementBase() : m_frame(NULL), m_focus(false) {} - virtual ~ElementBase() {} + virtual ~ElementBase() = default; bool is_active() const { return m_frame != NULL; } @@ -65,8 +64,8 @@ public: void mark_dirty(); protected: - display::Frame* m_frame; - bool m_focus; + display::Frame* m_frame{}; + bool m_focus{}; input::Bindings m_bindings; slot_type m_slot_exit; diff --git a/src/ui/element_chunks_seen.cc b/src/ui/element_chunks_seen.cc index 687250eb..a5a8af7a 100644 --- a/src/ui/element_chunks_seen.cc +++ b/src/ui/element_chunks_seen.cc @@ -48,9 +48,7 @@ namespace ui { ElementChunksSeen::ElementChunksSeen(core::Download* d) : - m_download(d), - m_window(NULL), - m_focus(0) { + m_download(d) { m_bindings[KEY_LEFT] = m_bindings['B' - '@'] = std::bind(&slot_type::operator(), &m_slot_exit); diff --git a/src/ui/element_chunks_seen.h b/src/ui/element_chunks_seen.h index 68b81304..345aa5d5 100644 --- a/src/ui/element_chunks_seen.h +++ b/src/ui/element_chunks_seen.h @@ -68,10 +68,9 @@ private: void receive_pageprev(); core::Download* m_download; - WChunksSeen* m_window; + WChunksSeen* m_window{}; - unsigned int m_focus; - + unsigned int m_focus{}; }; } diff --git a/src/ui/element_download_list.cc b/src/ui/element_download_list.cc index 74b875ce..939eae7c 100644 --- a/src/ui/element_download_list.cc +++ b/src/ui/element_download_list.cc @@ -18,10 +18,7 @@ namespace ui { -ElementDownloadList::ElementDownloadList() : - m_window(NULL), - m_view(NULL) { - +ElementDownloadList::ElementDownloadList() { receive_change_view("main"); if (m_view == NULL) diff --git a/src/ui/element_download_list.h b/src/ui/element_download_list.h index 67585dbc..354228d7 100644 --- a/src/ui/element_download_list.h +++ b/src/ui/element_download_list.h @@ -50,8 +50,8 @@ public: void toggle_layout(); private: - WDownloadList* m_window; - core::View* m_view; + WDownloadList* m_window{}; + core::View* m_view{}; }; } // namespace ui diff --git a/src/ui/element_file_list.cc b/src/ui/element_file_list.cc index 142410c8..677ee887 100644 --- a/src/ui/element_file_list.cc +++ b/src/ui/element_file_list.cc @@ -54,14 +54,8 @@ namespace ui { ElementFileList::ElementFileList(core::Download* d) : - m_download(d), - - m_state(DISPLAY_MAX_SIZE), - m_window(NULL), - m_elementInfo(NULL), - - m_selected(iterator(d->download()->file_list()->begin())), - m_collapsed(false) { + m_download(d), + m_selected(iterator(d->download()->file_list()->begin())) { m_bindings[KEY_LEFT] = m_bindings['B' - '@'] = std::bind(&slot_type::operator(), &m_slot_exit); m_bindings[KEY_RIGHT] = m_bindings['F' - '@'] = std::bind(&ElementFileList::receive_select, this); diff --git a/src/ui/element_file_list.h b/src/ui/element_file_list.h index 9afe1aef..6571d566 100644 --- a/src/ui/element_file_list.h +++ b/src/ui/element_file_list.h @@ -92,13 +92,13 @@ private: core::Download* m_download; - Display m_state; - WFileList* m_window; - ElementText* m_elementInfo; - + Display m_state{DISPLAY_MAX_SIZE}; + WFileList* m_window{}; + ElementText* m_elementInfo{}; + // Change to unsigned, please. iterator m_selected; - bool m_collapsed; + bool m_collapsed{}; }; } diff --git a/src/ui/element_log_complete.cc b/src/ui/element_log_complete.cc index ee268ab3..10d9d0ee 100644 --- a/src/ui/element_log_complete.cc +++ b/src/ui/element_log_complete.cc @@ -15,8 +15,7 @@ namespace ui { ElementLogComplete::ElementLogComplete(torrent::log_buffer* l) : - m_window(NULL), - m_log(l) { + m_log(l) { unsigned int signal_index = torrent::main_thread::thread()->signal_bitfield()->add_signal(std::bind(&ElementLogComplete::received_update, this)); diff --git a/src/ui/element_log_complete.h b/src/ui/element_log_complete.h index e867206d..a7d34ed6 100644 --- a/src/ui/element_log_complete.h +++ b/src/ui/element_log_complete.h @@ -63,7 +63,7 @@ public: private: void received_update(); - WLogComplete* m_window; + WLogComplete* m_window{}; torrent::log_buffer* m_log; }; diff --git a/src/ui/element_peer_list.cc b/src/ui/element_peer_list.cc index 216f9868..e462a592 100644 --- a/src/ui/element_peer_list.cc +++ b/src/ui/element_peer_list.cc @@ -56,8 +56,7 @@ namespace ui { ElementPeerList::ElementPeerList(core::Download* d) : - m_download(d), - m_state(DISPLAY_MAX_SIZE) { + m_download(d) { m_listItr = m_list.end(); diff --git a/src/ui/element_peer_list.h b/src/ui/element_peer_list.h index 12f78899..1da4d503 100644 --- a/src/ui/element_peer_list.h +++ b/src/ui/element_peer_list.h @@ -85,7 +85,7 @@ private: core::Download* m_download; - Display m_state; + Display m_state{DISPLAY_MAX_SIZE}; display::Window* m_windowList; ElementText* m_elementInfo; diff --git a/src/ui/element_string_list.cc b/src/ui/element_string_list.cc index 79f1adf2..169470a7 100644 --- a/src/ui/element_string_list.cc +++ b/src/ui/element_string_list.cc @@ -46,10 +46,6 @@ namespace ui { -ElementStringList::ElementStringList() : - m_window(NULL) { -} - void ElementStringList::activate(display::Frame* frame, bool focus) { if (is_active()) diff --git a/src/ui/element_string_list.h b/src/ui/element_string_list.h index 501e155a..83acee97 100644 --- a/src/ui/element_string_list.h +++ b/src/ui/element_string_list.h @@ -56,8 +56,6 @@ public: typedef display::WindowStringList WStringList; typedef std::list List; - ElementStringList(); - void activate(display::Frame* frame, bool focus = true); void disable(); @@ -101,7 +99,7 @@ public: void next_screen(); private: - WStringList* m_window; + WStringList* m_window{}; List m_list; }; diff --git a/src/ui/element_text.cc b/src/ui/element_text.cc index f1f3dea6..6428da21 100644 --- a/src/ui/element_text.cc +++ b/src/ui/element_text.cc @@ -49,9 +49,7 @@ namespace ui { ElementText::ElementText(rpc::target_type target) : - m_window(new WindowText(target)), - m_column(0), - m_columnWidth(0) { + m_window(new WindowText(target)) { // Move bindings into a function that defines default bindings. m_bindings[KEY_LEFT] = m_bindings['B' - '@'] = std::bind(&slot_type::operator(), &m_slot_exit); diff --git a/src/ui/element_text.h b/src/ui/element_text.h index 980dd419..38a9d988 100644 --- a/src/ui/element_text.h +++ b/src/ui/element_text.h @@ -102,8 +102,8 @@ public: private: WindowText* m_window; - unsigned int m_column; - extent_type m_columnWidth; + unsigned int m_column{}; + extent_type m_columnWidth{}; }; struct text_element_wrapper { diff --git a/src/ui/element_tracker_list.cc b/src/ui/element_tracker_list.cc index 752ff2a9..ec78429e 100644 --- a/src/ui/element_tracker_list.cc +++ b/src/ui/element_tracker_list.cc @@ -13,9 +13,7 @@ namespace ui { ElementTrackerList::ElementTrackerList(core::Download* d) : - m_download(d), - m_window(NULL), - m_focus(0) { + m_download(d) { m_bindings[KEY_LEFT] = m_bindings['B' - '@'] = std::bind(&slot_type::operator(), &m_slot_exit); diff --git a/src/ui/element_tracker_list.h b/src/ui/element_tracker_list.h index c0d5ccfb..32cfb52e 100644 --- a/src/ui/element_tracker_list.h +++ b/src/ui/element_tracker_list.h @@ -69,10 +69,10 @@ private: void receive_cycle_group(); core::Download* m_download; - WTrackerList* m_window; + WTrackerList* m_window{}; // Change to unsigned, please. - unsigned int m_focus; + unsigned int m_focus{}; }; } diff --git a/src/ui/element_transfer_list.cc b/src/ui/element_transfer_list.cc index cd0ae55b..a813ebce 100644 --- a/src/ui/element_transfer_list.cc +++ b/src/ui/element_transfer_list.cc @@ -48,9 +48,7 @@ namespace ui { ElementTransferList::ElementTransferList(core::Download* d) : - m_download(d), - m_window(NULL), - m_focus(0) { + m_download(d) { m_bindings[KEY_LEFT] = m_bindings['B' - '@'] = std::bind(&slot_type::operator(), &m_slot_exit); diff --git a/src/ui/element_transfer_list.h b/src/ui/element_transfer_list.h index 5db31da7..49fd3a50 100644 --- a/src/ui/element_transfer_list.h +++ b/src/ui/element_transfer_list.h @@ -68,10 +68,9 @@ private: void receive_pageprev(); core::Download* m_download; - WTransferList* m_window; + WTransferList* m_window{}; - unsigned int m_focus; - + unsigned int m_focus{}; }; } diff --git a/src/utils/directory.h b/src/utils/directory.h index d338b5fa..9a07868e 100644 --- a/src/utils/directory.h +++ b/src/utils/directory.h @@ -80,7 +80,7 @@ public: static const int update_sort = 0x1; static const int update_hide_dot = 0x2; - Directory() {} + Directory() = default; Directory(const std::string& path) : m_path(path) {} bool is_valid() const; diff --git a/src/utils/lockfile.h b/src/utils/lockfile.h index c54f8075..04d613ad 100644 --- a/src/utils/lockfile.h +++ b/src/utils/lockfile.h @@ -52,8 +52,6 @@ class Lockfile { public: typedef std::pair process_type; - Lockfile() : m_locked(false) {} - bool is_locked() const { return m_locked; } bool is_stale(); @@ -70,7 +68,7 @@ public: private: std::string m_path; - bool m_locked; + bool m_locked{}; }; }