From 484665f577267dac4ccd722bc28239a73c6efdb4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 8 Dec 2019 19:40:27 +0100 Subject: Cleanup: Add missing explicit initialisations --- ingen/URI.hpp | 2 +- src/Forge.cpp | 3 ++- src/Serialiser.cpp | 1 + src/SocketReader.cpp | 3 ++- src/TurtleWriter.cpp | 2 ++ src/URI.cpp | 30 ++++++++++++++++++------------ src/URIMap.cpp | 2 ++ src/World.cpp | 1 + src/server/ControlBindings.cpp | 1 + src/server/RunContext.cpp | 4 +++- src/server/SocketListener.cpp | 2 +- src/server/UndoStack.cpp | 8 ++++---- src/server/Worker.cpp | 2 +- 13 files changed, 39 insertions(+), 22 deletions(-) diff --git a/ingen/URI.hpp b/ingen/URI.hpp index 2d2f2aad..cbbfd46a 100644 --- a/ingen/URI.hpp +++ b/ingen/URI.hpp @@ -91,8 +91,8 @@ private: return Chunk((const char*)chunk.buf, chunk.len); } - SerdNode _node; SerdURI _uri; + SerdNode _node; }; inline bool operator==(const URI& lhs, const URI& rhs) diff --git a/src/Forge.cpp b/src/Forge.cpp index 90106ad5..cc1b12c8 100644 --- a/src/Forge.cpp +++ b/src/Forge.cpp @@ -26,7 +26,8 @@ namespace ingen { Forge::Forge(URIMap& map) - : _map(map) + : LV2_Atom_Forge() + , _map(map) { lv2_atom_forge_init(this, &map.urid_map_feature()->urid_map); } diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp index 7ab04f91..f0b5009e 100644 --- a/src/Serialiser.cpp +++ b/src/Serialiser.cpp @@ -56,6 +56,7 @@ namespace ingen { struct Serialiser::Impl { explicit Impl(World& world) : _root_path("/") + , _mode(Mode::TO_FILE) , _world(world) , _model(nullptr) , _sratom(sratom_new(&_world.uri_map().urid_map_feature()->urid_map)) diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp index d2fb3677..443c418f 100644 --- a/src/SocketReader.cpp +++ b/src/SocketReader.cpp @@ -42,6 +42,7 @@ SocketReader::SocketReader(ingen::World& world, SPtr sock) : _world(world) , _iface(iface) + , _env() , _inserter(nullptr) , _msg_node(nullptr) , _socket(std::move(sock)) @@ -141,7 +142,7 @@ SocketReader::run() // Make an AtomReader to call Ingen Interface methods based on Atom AtomReader ar(_world.uri_map(), _world.uris(), _world.log(), _iface); - struct pollfd pfd; + struct pollfd pfd{}; pfd.fd = _socket->fd(); pfd.events = POLLIN; pfd.revents = 0; diff --git a/src/TurtleWriter.cpp b/src/TurtleWriter.cpp index 43b40fa7..1deb2e13 100644 --- a/src/TurtleWriter.cpp +++ b/src/TurtleWriter.cpp @@ -41,6 +41,8 @@ TurtleWriter::TurtleWriter(URIMap& map, URIs& uris, URI uri) : AtomWriter(map, uris, *this) , _map(map) , _sratom(sratom_new(&map.urid_map_feature()->urid_map)) + , _base(SERD_NODE_NULL) + , _base_uri(SERD_URI_NULL) , _uri(std::move(uri)) , _wrote_prefixes(false) { diff --git a/src/URI.cpp b/src/URI.cpp index 5222c055..67a26ee9 100644 --- a/src/URI.cpp +++ b/src/URI.cpp @@ -23,35 +23,39 @@ namespace ingen { URI::URI() - : _node(SERD_NODE_NULL) - , _uri(SERD_URI_NULL) + : _uri(SERD_URI_NULL) + , _node(SERD_NODE_NULL) {} URI::URI(const std::string& str) - : _node(serd_node_new_uri_from_string((const uint8_t*)str.c_str(), + : _uri(SERD_URI_NULL) + , _node(serd_node_new_uri_from_string((const uint8_t*)str.c_str(), nullptr, &_uri)) {} URI::URI(const char* str) - : _node(serd_node_new_uri_from_string((const uint8_t*)str, nullptr, &_uri)) + : _uri(SERD_URI_NULL) + , _node(serd_node_new_uri_from_string((const uint8_t*)str, nullptr, &_uri)) {} URI::URI(const std::string& str, const URI& base) - : _node(serd_node_new_uri_from_string((const uint8_t*)str.c_str(), + : _uri(SERD_URI_NULL) + , _node(serd_node_new_uri_from_string((const uint8_t*)str.c_str(), &base._uri, &_uri)) {} URI::URI(SerdNode node) - : _node(serd_node_new_uri_from_node(&node, nullptr, &_uri)) + : _uri(SERD_URI_NULL) + , _node(serd_node_new_uri_from_node(&node, nullptr, &_uri)) { assert(node.type == SERD_URI); } URI::URI(SerdNode node, SerdURI uri) - : _node(node) - , _uri(uri) + : _uri(uri) + , _node(node) { assert(node.type == SERD_URI); } @@ -62,14 +66,16 @@ URI::URI(const Sord::Node& node) } URI::URI(const FilePath& path) - : _node(serd_node_new_file_uri((const uint8_t*)path.c_str(), + : _uri(SERD_URI_NULL) + , _node(serd_node_new_file_uri((const uint8_t*)path.c_str(), nullptr, &_uri, true)) {} URI::URI(const URI& uri) - : _node(serd_node_new_uri(&uri._uri, nullptr, &_uri)) + : _uri(SERD_URI_NULL) + , _node(serd_node_new_uri(&uri._uri, nullptr, &_uri)) {} URI& @@ -81,8 +87,8 @@ URI::operator=(const URI& uri) } URI::URI(URI&& uri) noexcept - : _node(uri._node) - , _uri(uri._uri) + : _uri(uri._uri) + , _node(uri._node) { uri._node = SERD_NODE_NULL; uri._uri = SERD_URI_NULL; diff --git a/src/URIMap.cpp b/src/URIMap.cpp index 121f47c2..0d43deed 100644 --- a/src/URIMap.cpp +++ b/src/URIMap.cpp @@ -36,6 +36,7 @@ URIMap::URIDMapFeature::URIDMapFeature(URIMap* map, LV2_URID_Map* impl, Log& log) : Feature(LV2_URID__map, &urid_map) + , urid_map() , log(log) { if (impl) { @@ -77,6 +78,7 @@ URIMap::URIDMapFeature::map(const char* uri) URIMap::URIDUnmapFeature::URIDUnmapFeature(URIMap* map, LV2_URID_Unmap* impl) : Feature(LV2_URID__unmap, &urid_unmap) + , urid_unmap() { if (impl) { urid_unmap = *impl; diff --git a/src/World.cpp b/src/World.cpp index 42cbff6f..41e69826 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -95,6 +95,7 @@ public: , uri_map(log, map, unmap) , forge(uri_map) , uris(forge, &uri_map, lilv_world.get()) + , lv2_log() , conf(forge) , log(lv2_log, uris) { diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index f1380462..2e1f9d06 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -51,6 +51,7 @@ ControlBindings::ControlBindings(Engine& engine) engine.world().uris().atom_Sequence, 0, 4096)) // FIXME: capacity? + , _forge() { lv2_atom_forge_init( &_forge, &engine.world().uri_map().urid_map_feature()->urid_map); diff --git a/src/server/RunContext.cpp b/src/server/RunContext.cpp index 0eabb1ee..68812c02 100644 --- a/src/server/RunContext.cpp +++ b/src/server/RunContext.cpp @@ -66,6 +66,7 @@ RunContext::RunContext(Engine& engine, , _end(0) , _offset(0) , _nframes(0) + , _rate(0) , _realtime(true) {} @@ -79,6 +80,7 @@ RunContext::RunContext(const RunContext& copy) , _end(copy._end) , _offset(copy._offset) , _nframes(copy._nframes) + , _rate(copy._rate) , _realtime(copy._realtime) {} @@ -168,7 +170,7 @@ RunContext::set_priority(int priority) if (_thread) { pthread_t pthread = _thread->native_handle(); const int policy = (priority > 0) ? SCHED_FIFO : SCHED_OTHER; - sched_param sp; + sched_param sp{}; sp.sched_priority = (priority > 0) ? priority : 0; if (pthread_setschedparam(pthread, policy, &sp)) { _engine.log().error( diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp index ecce1649..ac4b9f9e 100644 --- a/src/server/SocketListener.cpp +++ b/src/server/SocketListener.cpp @@ -46,7 +46,7 @@ static std::string get_link_target(const char* link_path) { // Stat the link to get the required size for the target path - struct stat link_stat; + struct stat link_stat{}; if (lstat(link_path, &link_stat)) { return std::string(); } diff --git a/src/server/UndoStack.cpp b/src/server/UndoStack.cpp index e04daa1a..9574d393 100644 --- a/src/server/UndoStack.cpp +++ b/src/server/UndoStack.cpp @@ -118,16 +118,16 @@ UndoStack::pop() } struct BlankIDs { - BlankIDs(char c='b') : n(0), c(c) {} + BlankIDs(char c='b') : c(c) {} SerdNode get() { snprintf(buf, sizeof(buf), "%c%u", c, n++); return serd_node_from_string(SERD_BLANK, USTR(buf)); } - char buf[16]; - unsigned n; - const char c; + char buf[16]{}; + unsigned n{0}; + const char c{'b'}; }; struct ListContext { diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp index 1fd887d0..68926278 100644 --- a/src/server/Worker.cpp +++ b/src/server/Worker.cpp @@ -137,7 +137,7 @@ void Worker::run() { while (_sem.wait() && !_exit_flag) { - MessageHeader msg; + MessageHeader msg{}; if (_requests.read_space() > sizeof(msg)) { if (_requests.read(sizeof(msg), &msg) != sizeof(msg)) { _log.error("Error reading header from work request ring\n"); -- cgit v1.2.1