From ad4cec932249445160017cd2cf57917c1c2e2501 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 3 Feb 2023 14:43:19 -0500 Subject: Suppress/fix new warnings in clang-tidy 15 --- .clang-tidy | 1 + include/ingen/ColorContext.hpp | 2 +- src/ClashAvoider.cpp | 4 ++-- src/Configuration.cpp | 17 ++++++++------ src/LV2Features.cpp | 2 +- src/Log.cpp | 8 +++---- src/Parser.cpp | 28 +++++++++++------------ src/Serialiser.cpp | 17 +++++++------- src/SocketReader.cpp | 8 +++---- src/SocketWriter.cpp | 2 +- src/StreamWriter.cpp | 2 +- src/URI.cpp | 45 +++++++++++++++++-------------------- src/URIMap.cpp | 10 ++++----- src/client/ClientStore.cpp | 24 ++++++++++---------- src/client/GraphModel.cpp | 2 +- src/client/PluginModel.cpp | 2 +- src/client/PluginUI.cpp | 16 ++++++------- src/gui/Arc.cpp | 4 ++-- src/gui/BreadCrumbs.cpp | 2 +- src/gui/ConnectWindow.cpp | 2 +- src/gui/GraphBox.cpp | 6 ++--- src/gui/GraphCanvas.cpp | 14 ++++++------ src/gui/GraphTreeWindow.cpp | 12 +++++----- src/gui/GraphView.cpp | 5 +++-- src/gui/LoadGraphWindow.cpp | 4 ++-- src/gui/LoadPluginWindow.cpp | 10 ++++----- src/gui/MessagesWindow.cpp | 10 ++++----- src/gui/NewSubgraphWindow.cpp | 2 +- src/gui/NodeMenu.cpp | 2 +- src/gui/NodeModule.cpp | 7 +++--- src/gui/PluginMenu.cpp | 12 +++++----- src/gui/Port.cpp | 9 ++++---- src/gui/PropertiesWindow.cpp | 18 +++++++-------- src/gui/RDFS.cpp | 6 ++--- src/gui/ThreadedLoader.cpp | 10 ++++----- src/gui/URIEntry.cpp | 2 +- src/gui/ingen_gui.cpp | 2 +- src/ingen/ingen.cpp | 2 +- src/server/BlockImpl.cpp | 2 +- src/server/Broadcaster.cpp | 8 +++---- src/server/CompiledGraph.cpp | 2 +- src/server/ControlBindings.cpp | 7 +++--- src/server/LV2Block.cpp | 34 ++++++++++++++-------------- src/server/LV2Plugin.cpp | 2 +- src/server/PortImpl.cpp | 14 ++++++------ src/server/PreProcessor.cpp | 4 ++-- src/server/RunContext.cpp | 6 ++--- src/server/UndoStack.cpp | 10 ++++----- src/server/Worker.cpp | 10 ++++----- src/server/events/Connect.cpp | 4 ++-- src/server/events/Copy.cpp | 8 +++---- src/server/events/CreateBlock.cpp | 2 +- src/server/events/CreateGraph.cpp | 2 +- src/server/events/CreatePort.cpp | 2 +- src/server/events/Delete.cpp | 4 ++-- src/server/events/Delta.cpp | 6 ++--- src/server/events/Disconnect.cpp | 4 ++-- src/server/events/DisconnectAll.cpp | 2 +- src/server/events/Get.cpp | 4 ++-- src/server/events/Move.cpp | 4 ++-- src/server/events/SetPortValue.cpp | 8 +++---- src/server/ingen_lv2.cpp | 36 ++++++++++++++--------------- src/server/internals/Time.cpp | 4 ++-- tests/ingen_bench.cpp | 12 +++++----- tests/ingen_test.cpp | 12 +++++----- 65 files changed, 274 insertions(+), 270 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 1b5503c8..1e78ab46 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,6 +5,7 @@ Checks: > -*-non-private-member-variables-in-classes, -abseil-*, -altera-*, + -bugprone-assignment-in-if-condition, -cppcoreguidelines-macro-usage, -fuchsia-default-arguments-calls, -fuchsia-default-arguments-declarations, diff --git a/include/ingen/ColorContext.hpp b/include/ingen/ColorContext.hpp index 251812b8..c1486b5c 100644 --- a/include/ingen/ColorContext.hpp +++ b/include/ingen/ColorContext.hpp @@ -34,7 +34,7 @@ public: ColorContext(const ColorContext&) = delete; ColorContext& operator=(const ColorContext&) = delete; ColorContext(ColorContext&&) = delete; - ColorContext& operator=(ColorContext&) = delete; + ColorContext& operator=(ColorContext&&) = delete; private: FILE* _stream; diff --git a/src/ClashAvoider.cpp b/src/ClashAvoider.cpp index 9c1d8f28..b782bcc7 100644 --- a/src/ClashAvoider.cpp +++ b/src/ClashAvoider.cpp @@ -118,8 +118,8 @@ ClashAvoider::map_path(const raul::Path& in) name = "_"; } - raul::Symbol sym(name); - std::string str = ss.str(); + const raul::Symbol sym{name}; + const std::string str{ss.str()}; auto i = _symbol_map.emplace(in, raul::Path(str)); diff --git a/src/Configuration.cpp b/src/Configuration.cpp index aaf421cb..67a91dae 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -146,8 +146,8 @@ Configuration::set_value_from_string(Configuration::Option& option, const std::string& value) { if (option.type == _forge.Int) { - char* endptr = nullptr; - int intval = static_cast(strtol(value.c_str(), &endptr, 10)); + char* endptr = nullptr; + const int intval = static_cast(strtol(value.c_str(), &endptr, 10)); if (endptr && *endptr == '\0') { option.value = _forge.make(intval); } else { @@ -247,8 +247,11 @@ Configuration::load(const FilePath& path) SerdEnv* env = serd_env_new(&node); model.load_file(env, SERD_TURTLE, uri, uri); - Sord::Node nodemm(world, Sord::Node::URI, reinterpret_cast(node.buf)); - Sord::Node nil; + const Sord::Node nodemm{world, + Sord::Node::URI, + reinterpret_cast(node.buf)}; + + const Sord::Node nil; for (auto i = model.find(nodemm, nil, nil); !i.end(); ++i) { const auto& pred = i.get_predicate(); const auto& obj = i.get_object(); @@ -287,8 +290,8 @@ Configuration::save(URIMap& uri_map, } // Attempt to open file for writing - std::unique_ptr file{fopen(path.c_str(), "w"), - &fclose}; + const std::unique_ptr file{fopen(path.c_str(), "w"), + &fclose}; if (!file) { throw FileError(fmt("Failed to open file %1% (%2%)", path, strerror(errno))); @@ -343,7 +346,7 @@ Configuration::save(URIMap& uri_map, } const std::string key(std::string("ingen:") + o.second.key); - SerdNode pred = serd_node_from_string( + const SerdNode pred = serd_node_from_string( SERD_CURIE, reinterpret_cast(key.c_str())); sratom_write(sratom, &uri_map.urid_unmap(), 0, &base, &pred, value.type(), value.size(), value.get_body()); diff --git a/src/LV2Features.cpp b/src/LV2Features.cpp index 65fe6f6b..7d9003c0 100644 --- a/src/LV2Features.cpp +++ b/src/LV2Features.cpp @@ -71,7 +71,7 @@ LV2Features::lv2_features(World& world, Node* node) const { FeatureArray::FeatureVector vec; for (const auto& f : _features) { - std::shared_ptr fptr = f->feature(world, node); + const std::shared_ptr fptr = f->feature(world, node); if (fptr) { vec.push_back(fptr); } diff --git a/src/Log.cpp b/src/Log.cpp index e05caa21..e17e1555 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -96,16 +96,16 @@ Log::vtprintf(LV2_URID type, const char* fmt, va_list args) if (_log) { ret = _log->vprintf(_log->handle, type, fmt, args); } else if (type == _uris.log_Error) { - ColorContext ctx(stderr, ColorContext::Color::RED); + const ColorContext ctx{stderr, ColorContext::Color::RED}; ret = vfprintf(stderr, fmt, args); } else if (type == _uris.log_Warning) { - ColorContext ctx(stderr, ColorContext::Color::YELLOW); + const ColorContext ctx{stderr, ColorContext::Color::YELLOW}; ret = vfprintf(stderr, fmt, args); } else if (type == _uris.log_Note) { - ColorContext ctx(stderr, ColorContext::Color::GREEN); + const ColorContext ctx{stderr, ColorContext::Color::GREEN}; ret = vfprintf(stdout, fmt, args); } else if (_trace && type == _uris.log_Trace) { - ColorContext ctx(stderr, ColorContext::Color::GREEN); + const ColorContext ctx{stderr, ColorContext::Color::GREEN}; ret = vfprintf(stderr, fmt, args); } else { fprintf(stderr, "Unknown log type %u\n", type); diff --git a/src/Parser.cpp b/src/Parser.cpp index 58801dba..c66f852d 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -284,8 +284,8 @@ parse_block(ingen::World& world, serd_uri_parse(reinterpret_cast(base_uri.c_str()), &base_uri_parts); - SerdURI ignored; - SerdNode sub_uri = + SerdURI ignored; + const SerdNode sub_uri = serd_node_new_uri_from_string(type_uri, &base_uri_parts, &ignored); const std::string sub_uri_str = @@ -300,7 +300,7 @@ parse_block(ingen::World& world, sub_model.load_file(env, SERD_TURTLE, sub_file); serd_env_free(env); - Sord::URI sub_node(*world.rdf_world(), sub_file); + const Sord::URI sub_node{*world.rdf_world(), sub_file}; parse_graph(world, target, sub_model, @@ -358,7 +358,7 @@ parse_graph(ingen::World& world, } // Create graph - Properties props = get_properties(world, model, subject, ctx, data); + const Properties props = get_properties(world, model, subject, ctx, data); target.put(path_to_uri(graph_path), props, ctx); // For each port on this graph @@ -397,8 +397,8 @@ parse_graph(ingen::World& world, // For each block in this graph for (auto n = model.find(subject, ingen_block, nil); !n.end(); ++n) { - Sord::Node node = n.get_object(); - URI node_uri = node; + const Sord::Node node = n.get_object(); + const URI node_uri = node; assert(!node_uri.path().empty() && node_uri.path() != "/"); const raul::Path block_path = graph_path.child( raul::Symbol(FilePath(node_uri.path()).stem().string())); @@ -583,19 +583,19 @@ parse(ingen::World& world, symbol, data); } else if (types.find(block_class) != types.end()) { - const raul::Path rel_path(*get_path(base_uri, s)); + const raul::Path rel_path{*get_path(base_uri, s)}; const raul::Path path = parent ? parent->child(rel_path) : rel_path; ret = parse_block(world, target, model, base_uri, s, path, data); } else if (types.find(in_port_class) != types.end() || types.find(out_port_class) != types.end()) { - const raul::Path rel_path(*get_path(base_uri, s)); + const raul::Path rel_path{*get_path(base_uri, s)}; const raul::Path path = parent ? parent->child(rel_path) : rel_path; const Properties properties = get_properties(world, model, s, Resource::Graph::DEFAULT, data); target.put(path_to_uri(path), properties); ret = path; } else if (types.find(arc_class) != types.end()) { - raul::Path parent_path(parent ? parent.value() : raul::Path("/")); + const raul::Path parent_path{parent ? parent.value() : raul::Path("/")}; parse_arc(world, target, model, base_uri, s, parent_path); } else { world.log().error("Subject has no known types\n"); @@ -624,7 +624,7 @@ Parser::parse_file(ingen::World& world, const FilePath manifest_path = (is_bundle ? file_path / "manifest.ttl" : file_path); - URI manifest_uri(manifest_path); + const URI manifest_uri{manifest_path}; // Find graphs in manifest const std::set resources = @@ -659,10 +659,10 @@ Parser::parse_file(ingen::World& world, } // Initialise parsing environment - const URI file_uri = URI(file_path); - const auto* uri_c_str = reinterpret_cast(uri.c_str()); - SerdNode base_node = serd_node_from_string(SERD_URI, uri_c_str); - SerdEnv* env = serd_env_new(&base_node); + const URI file_uri = URI(file_path); + const auto* uri_c_str = reinterpret_cast(uri.c_str()); + const SerdNode base_node = serd_node_from_string(SERD_URI, uri_c_str); + SerdEnv* env = serd_env_new(&base_node); // Load graph into model Sord::Model model(*world.rdf_world(), diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp index 7bfa4211..64a9993b 100644 --- a/src/Serialiser.cpp +++ b/src/Serialiser.cpp @@ -204,7 +204,7 @@ Serialiser::Impl::write_bundle(const std::shared_ptr& graph, start_to_file(graph->path(), main_file); - std::set plugins = + const std::set plugins = serialise_graph(graph, Sord::URI(_model->world(), main_file, _base_uri)); @@ -260,7 +260,7 @@ Serialiser::Impl::finish() { std::string ret; if (_mode == Mode::TO_FILE) { - SerdStatus st = _model->write_to_file(_base_uri, SERD_TURTLE); + const SerdStatus st = _model->write_to_file(_base_uri, SERD_TURTLE); if (st) { _world.log().error("Error writing file %1% (%2%)\n", _base_uri, @@ -356,7 +356,7 @@ Serialiser::Impl::serialise_graph(const std::shared_ptr& graph, } if (n->second->graph_type() == Node::GraphType::GRAPH) { - std::shared_ptr subgraph = n->second; + const std::shared_ptr subgraph = n->second; SerdURI base_uri; serd_uri_parse(reinterpret_cast(_base_uri.c_str()), @@ -377,7 +377,7 @@ Serialiser::Impl::serialise_graph(const std::shared_ptr& graph, subgraph_node.buf)); // Save our state - URI my_base_uri = _base_uri; + const URI my_base_uri = _base_uri; Sord::Model* my_model = _model; // Write child bundle within this bundle @@ -396,7 +396,7 @@ Serialiser::Impl::serialise_graph(const std::shared_ptr& graph, serd_node_free(&subgraph_node); } else if (n->second->graph_type() == Node::GraphType::BLOCK) { - std::shared_ptr block = n->second; + const std::shared_ptr block = n->second; const Sord::URI class_id(world, block->plugin()->uri()); const Sord::Node block_id(path_rdf_node(n->second->path())); @@ -480,7 +480,7 @@ Serialiser::Impl::serialise_port(const Node* port, Resource::Graph context, const Sord::Node& port_id) { - URIs& uris = _world.uris(); + const URIs& uris = _world.uris(); Sord::World& world = _model->world(); Properties props = port->properties(context); @@ -558,9 +558,8 @@ void Serialiser::Impl::serialise_properties(Sord::Node id, const Properties& props) { LV2_URID_Unmap* unmap = &_world.uri_map().urid_unmap(); - SerdNode base = serd_node_from_string(SERD_URI, - reinterpret_cast( - _base_uri.c_str())); + const SerdNode base = serd_node_from_string( + SERD_URI, reinterpret_cast(_base_uri.c_str())); SerdEnv* env = serd_env_new(&base); SordInserter* inserter = sord_inserter_new(_model->c_obj(), env); diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp index 83854bf9..93677c6c 100644 --- a/src/SocketReader.cpp +++ b/src/SocketReader.cpp @@ -123,7 +123,7 @@ SocketReader::run() AtomForge forge(map); { // Lock RDF world - std::lock_guard lock(_world.rdf_mutex()); + const std::lock_guard lock{_world.rdf_mutex()}; // Use as base URI, so relative URIs are like bundle paths base_uri = sord_new_uri(world->c_obj(), @@ -174,10 +174,10 @@ SocketReader::run() } // Lock RDF world - std::lock_guard lock(_world.rdf_mutex()); + const std::lock_guard lock{_world.rdf_mutex()}; // Read until the next '.' - SerdStatus st = serd_reader_read_chunk(reader); + const SerdStatus st = serd_reader_read_chunk(reader); if (st == SERD_FAILURE || !_msg_node) { continue; // Read nothing, e.g. just whitespace } @@ -200,7 +200,7 @@ SocketReader::run() } // Lock RDF world - std::lock_guard lock(_world.rdf_mutex()); + const std::lock_guard lock{_world.rdf_mutex()}; // Destroy everything sord_inserter_free(_inserter); diff --git a/src/SocketWriter.cpp b/src/SocketWriter.cpp index 6bbab6cb..e6af8750 100644 --- a/src/SocketWriter.cpp +++ b/src/SocketWriter.cpp @@ -52,7 +52,7 @@ SocketWriter::message(const Message& message) size_t SocketWriter::text_sink(const void* buf, size_t len) { - ssize_t ret = send(_socket->fd(), buf, len, MSG_NOSIGNAL); + const ssize_t ret = send(_socket->fd(), buf, len, MSG_NOSIGNAL); if (ret < 0) { return 0; } diff --git a/src/StreamWriter.cpp b/src/StreamWriter.cpp index d8a93a0b..0d3d97d6 100644 --- a/src/StreamWriter.cpp +++ b/src/StreamWriter.cpp @@ -34,7 +34,7 @@ StreamWriter::StreamWriter(URIMap& map, size_t StreamWriter::text_sink(const void* buf, size_t len) { - ColorContext ctx(_stream, _color); + const ColorContext ctx{_stream, _color}; return fwrite(buf, 1, len, _stream); } diff --git a/src/URI.cpp b/src/URI.cpp index cc40a9a3..501b4eb9 100644 --- a/src/URI.cpp +++ b/src/URI.cpp @@ -24,10 +24,7 @@ namespace ingen { -URI::URI() - : _uri(SERD_URI_NULL) - , _node(SERD_NODE_NULL) -{} +URI::URI() : _uri(SERD_URI_NULL), _node(SERD_NODE_NULL) {} URI::URI(const std::string& str) : _uri(SERD_URI_NULL) @@ -35,14 +32,16 @@ URI::URI(const std::string& str) str.c_str()), nullptr, &_uri)) -{} +{ +} URI::URI(const char* str) : _uri(SERD_URI_NULL) , _node(serd_node_new_uri_from_string(reinterpret_cast(str), nullptr, &_uri)) -{} +{ +} URI::URI(const std::string& str, const URI& base) : _uri(SERD_URI_NULL) @@ -50,25 +49,22 @@ URI::URI(const std::string& str, const URI& base) str.c_str()), &base._uri, &_uri)) -{} +{ +} URI::URI(SerdNode node) - : _uri(SERD_URI_NULL) - , _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) - : _uri(uri) - , _node(node) +URI::URI(SerdNode node, SerdURI uri) : _uri(uri), _node(node) { assert(node.type == SERD_URI); } -URI::URI(const Sord::Node& node) - : URI(*node.to_serd_node()) -{} +URI::URI(const Sord::Node& node) : URI(*node.to_serd_node()) {} URI::URI(const FilePath& path) : _uri(SERD_URI_NULL) @@ -77,12 +73,13 @@ URI::URI(const FilePath& path) nullptr, &_uri, true)) -{} +{ +} URI::URI(const URI& uri) - : _uri(SERD_URI_NULL) - , _node(serd_node_new_uri(&uri._uri, nullptr, &_uri)) -{} + : _uri(SERD_URI_NULL), _node(serd_node_new_uri(&uri._uri, nullptr, &_uri)) +{ +} URI& URI::operator=(const URI& uri) @@ -95,9 +92,7 @@ URI::operator=(const URI& uri) return *this; } -URI::URI(URI&& uri) noexcept - : _uri(uri._uri) - , _node(uri._node) +URI::URI(URI&& uri) noexcept : _uri(uri._uri), _node(uri._node) { uri._node = SERD_NODE_NULL; uri._uri = SERD_URI_NULL; @@ -123,8 +118,10 @@ URI::~URI() URI URI::make_relative(const URI& base) const { - SerdURI uri; - SerdNode node = serd_node_new_relative_uri(&_uri, &base._uri, nullptr, &uri); + SerdURI uri; + const SerdNode node = + serd_node_new_relative_uri(&_uri, &base._uri, nullptr, &uri); + return {node, uri}; } diff --git a/src/URIMap.cpp b/src/URIMap.cpp index 0d6654a5..bb484529 100644 --- a/src/URIMap.cpp +++ b/src/URIMap.cpp @@ -50,9 +50,9 @@ LV2_URID URIMap::URIDMapFeature::default_map(LV2_URID_Map_Handle h, const char* c_uri) { - auto* const map(static_cast(h)); - std::string uri(c_uri); - std::lock_guard lock(map->_mutex); + auto* const map{static_cast(h)}; + std::string uri{c_uri}; + const std::lock_guard lock{map->_mutex}; auto record = map->_map.emplace(uri, map->_map.size() + 1); const auto id = record.first->second; @@ -92,8 +92,8 @@ const char* URIMap::URIDUnmapFeature::default_unmap(LV2_URID_Unmap_Handle h, LV2_URID urid) { - auto* const map(static_cast(h)); - std::lock_guard lock(map->_mutex); + auto* const map{static_cast(h)}; + const std::lock_guard lock{map->_mutex}; return (urid > 0 && urid <= map->_unmap.size() ? map->_unmap[urid - 1].c_str() diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index c492d3e6..f1fd2128 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -75,7 +75,7 @@ ClientStore::add_object(const std::shared_ptr& object) std::dynamic_pointer_cast(existing->second)->set(object); } else { if (!object->path().is_root()) { - std::shared_ptr parent = _object(object->path().parent()); + const std::shared_ptr parent = _object(object->path().parent()); if (parent) { assert(object->path().is_child_of(parent->path())); object->set_parent(parent); @@ -200,7 +200,7 @@ ClientStore::resource(const URI& uri) const void ClientStore::add_plugin(const std::shared_ptr& pm) { - std::shared_ptr existing = _plugin(pm->uri()); + const std::shared_ptr existing = _plugin(pm->uri()); if (existing) { existing->set(pm); } else { @@ -285,7 +285,7 @@ ClientStore::operator()(const Put& msg) if (_uris.ingen_Graph == type) { is_graph = true; } else if (_uris.ingen_Internal == type || _uris.lv2_Plugin == type) { - std::shared_ptr p(new PluginModel(uris(), uri, type, properties)); + const std::shared_ptr p{new PluginModel(uris(), uri, type, properties)}; add_plugin(p); return; } @@ -309,7 +309,7 @@ ClientStore::operator()(const Put& msg) } if (is_graph) { - std::shared_ptr model(new GraphModel(uris(), path)); + const std::shared_ptr model{new GraphModel(uris(), path)}; model->set_properties(properties); add_object(model); } else if (is_block) { @@ -330,14 +330,14 @@ ClientStore::operator()(const Put& msg) add_plugin(plug); } - std::shared_ptr bm(new BlockModel(uris(), plug, path)); + const std::shared_ptr bm{new BlockModel(uris(), plug, path)}; bm->set_properties(properties); add_object(bm); } else { _log.warn("Block %1% has no prototype\n", path.c_str()); } } else if (is_port) { - PortModel::Direction pdir = (is_output) + const PortModel::Direction pdir = (is_output) ? PortModel::Direction::OUTPUT : PortModel::Direction::INPUT; uint32_t index = 0; @@ -346,7 +346,7 @@ ClientStore::operator()(const Put& msg) index = i->second.get(); } - std::shared_ptr p(new PortModel(uris(), path, index, pdir)); + const std::shared_ptr p{new PortModel(uris(), path, index, pdir)}; p->set_properties(properties); add_object(p); } else { @@ -370,7 +370,7 @@ ClientStore::operator()(const Delta& msg) const raul::Path path(uri_to_path(uri)); - std::shared_ptr obj = _object(path); + const std::shared_ptr obj = _object(path); if (obj) { obj->remove_properties(msg.remove); obj->add_properties(msg.add); @@ -391,7 +391,7 @@ ClientStore::operator()(const SetProperty& msg) predicate.c_str(), _uris.forge.str(value, false)); return; } - std::shared_ptr subject = _resource(subject_uri); + const std::shared_ptr subject = _resource(subject_uri); if (subject) { if (predicate == _uris.ingen_activity) { /* Activity is transient, trigger any live actions (like GUI @@ -401,7 +401,7 @@ ClientStore::operator()(const SetProperty& msg) subject->set_property(predicate, value, msg.ctx); } } else { - std::shared_ptr plugin = _plugin(subject_uri); + const std::shared_ptr plugin = _plugin(subject_uri); if (plugin) { plugin->set_property(predicate, value); } else if (predicate != _uris.ingen_activity) { @@ -449,8 +449,8 @@ ClientStore::attempt_connection(const raul::Path& tail_path, auto head = std::dynamic_pointer_cast(_object(head_path)); if (tail && head) { - std::shared_ptr graph = connection_graph(tail_path, head_path); - std::shared_ptr arc(new ArcModel(tail, head)); + const std::shared_ptr graph = connection_graph(tail_path, head_path); + const std::shared_ptr arc(new ArcModel(tail, head)); graph->add_arc(arc); return true; } diff --git a/src/client/GraphModel.cpp b/src/client/GraphModel.cpp index 2a998fdf..45d0eb31 100644 --- a/src/client/GraphModel.cpp +++ b/src/client/GraphModel.cpp @@ -134,7 +134,7 @@ GraphModel::add_arc(const std::shared_ptr& arc) assert(arc->head()->parent().get() == this || arc->head()->parent()->parent().get() == this); - std::shared_ptr existing = get_arc( + const std::shared_ptr existing = get_arc( arc->tail().get(), arc->head().get()); if (existing) { diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 4371132c..2485fe65 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -106,7 +106,7 @@ PluginModel::get_property(const URI& key) const } str = str.substr(last_delim + 1); - std::string symbol = raul::Symbol::symbolify(str); + const std::string symbol = raul::Symbol::symbolify(str); set_property(_uris.lv2_symbol, _uris.forge.alloc(symbol)); return get_property(key); } diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index f0c3834a..a8ae0ee5 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -88,9 +88,9 @@ lv2_ui_write(SuilController controller, } else if (format == uris.atom_eventTransfer.urid()) { const auto* atom = static_cast(buffer); - Atom val = Forge::alloc(atom->size, - atom->type, - LV2_ATOM_BODY_CONST(atom)); + const Atom val = + Forge::alloc(atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); + ui->signal_property_changed()(port->uri(), uris.ingen_activity, val, @@ -122,8 +122,8 @@ lv2_ui_subscribe(SuilController controller, uint32_t protocol, const LV2_Feature* const* features) { - auto* const ui = static_cast(controller); - std::shared_ptr port = get_port(ui, port_index); + auto* const ui = static_cast(controller); + const std::shared_ptr port = get_port(ui, port_index); if (!port) { return 1; } @@ -173,7 +173,7 @@ PluginUI::PluginUI(ingen::World& world, PluginUI::~PluginUI() { - for (uint32_t i : _subscribed_ports) { + for (const uint32_t i : _subscribed_ports) { lv2_ui_unsubscribe(this, i, 0, nullptr); } suil_instance_free(_instance); @@ -259,7 +259,7 @@ PluginUI::instantiate() plugin_uri, lilv_node_as_string(_ui_node)); } else if (!strcmp(lilv_node_as_uri(plug), plugin_uri.c_str())) { // Notification is valid and for this plugin - uint32_t index = lv2_ui_port_index(this, lilv_node_as_string(sym)); + const uint32_t index = lv2_ui_port_index(this, lilv_node_as_string(sym)); if (index != LV2UI_INVALID_PORT_INDEX) { lv2_ui_subscribe(this, index, 0, nullptr); _subscribed_ports.insert(index); @@ -293,7 +293,7 @@ PluginUI::instantiate() if (!_instance) { _world.log().error("Failed to instantiate LV2 UI\n"); // Cancel any subscriptions - for (uint32_t i : _subscribed_ports) { + for (const uint32_t i : _subscribed_ports) { lv2_ui_unsubscribe(this, i, 0, nullptr); } return false; diff --git a/src/gui/Arc.cpp b/src/gui/Arc.cpp index c9260d12..6d13593e 100644 --- a/src/gui/Arc.cpp +++ b/src/gui/Arc.cpp @@ -41,8 +41,8 @@ Arc::Arc(Ganv::Canvas& canvas, Ganv::Node* dst) : Ganv::Edge(canvas, src, dst), _arc_model(model) { - std::shared_ptr tparent = model->tail()->parent(); - std::shared_ptr tparent_block; + const std::shared_ptr tparent = model->tail()->parent(); + std::shared_ptr tparent_block; if ((tparent_block = std::dynamic_pointer_cast(tparent))) { if (tparent_block->plugin_uri() == NS_INTERNALS "BlockDelay") { g_object_set(_gobj, "dash-length", 4.0, nullptr); diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp index 2033457d..2323afb4 100644 --- a/src/gui/BreadCrumbs.cpp +++ b/src/gui/BreadCrumbs.cpp @@ -64,7 +64,7 @@ void BreadCrumbs::build(const raul::Path& path, const std::shared_ptr& view) { - bool old_enable_signal = _enable_signal; + const bool old_enable_signal = _enable_signal; _enable_signal = false; if (!_breadcrumbs.empty() && (path.is_parent_of(_full_path) || path == _full_path)) { diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index 2fd3be8c..6938ae93 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -195,7 +195,7 @@ ConnectWindow::connect_remote(const URI& uri) auto sci = std::make_shared(); auto qi = std::make_shared(sci); - std::shared_ptr iface(world.new_interface(uri, qi)); + const std::shared_ptr iface{world.new_interface(uri, qi)}; if (iface) { world.set_interface(iface); _app->attach(qi); diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 14258a5a..414bbef4 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -228,7 +228,7 @@ GraphBox::GraphBox(BaseObjectType* cobject, _menu_view_graph_properties->signal_activate().connect( sigc::mem_fun(this, &GraphBox::event_show_properties)); - Glib::RefPtr clipboard = Gtk::Clipboard::get(); + const Glib::RefPtr clipboard = Gtk::Clipboard::get(); clipboard->signal_owner_change().connect( sigc::mem_fun(this, &GraphBox::event_clipboard_changed)); @@ -250,7 +250,7 @@ std::shared_ptr GraphBox::create(App& app, const std::shared_ptr& graph) { GraphBox* result = nullptr; - Glib::RefPtr xml = WidgetFactory::create("graph_win"); + const Glib::RefPtr xml = WidgetFactory::create("graph_win"); xml->get_widget_derived("graph_win_vbox", result); result->init_box(app); result->set_graph(graph, nullptr); @@ -535,7 +535,7 @@ GraphBox::event_show_engine() void GraphBox::event_clipboard_changed(GdkEventOwnerChange* ev) { - Glib::RefPtr clipboard = Gtk::Clipboard::get(); + const Glib::RefPtr clipboard = Gtk::Clipboard::get(); _menu_paste->set_sensitive(clipboard->wait_is_text_available()); } diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 74542c87..84917c34 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -131,7 +131,7 @@ GraphCanvas::GraphCanvas(App& app, , _app(app) , _graph(std::move(graph)) { - Glib::RefPtr xml = WidgetFactory::create("canvas_menu"); + const Glib::RefPtr xml = WidgetFactory::create("canvas_menu"); xml->get_widget("canvas_menu", _menu); xml->get_widget("canvas_menu_add_audio_input", _menu_add_audio_input); @@ -302,7 +302,7 @@ GraphCanvas::build() static void show_module_human_names(GanvNode* node, void* data) { - bool b = *static_cast(data); + const bool b = *static_cast(data); if (GANV_IS_MODULE(node)) { Ganv::Module* module = Glib::wrap(GANV_MODULE(node)); auto* nmod = dynamic_cast(module); @@ -688,7 +688,7 @@ serialise_arc(GanvEdge* arc, void* data) void GraphCanvas::copy_selection() { - std::lock_guard lock(_app.world().rdf_mutex()); + const std::lock_guard lock{_app.world().rdf_mutex()}; Serialiser serialiser(_app.world()); serialiser.start_to_string(_graph->path(), _graph->base_uri()); @@ -696,7 +696,7 @@ GraphCanvas::copy_selection() for_each_selected_node(serialise_node, &serialiser); for_each_selected_edge(serialise_arc, &serialiser); - Glib::RefPtr clipboard = Gtk::Clipboard::get(); + const Glib::RefPtr clipboard = Gtk::Clipboard::get(); clipboard->set_text(serialiser.finish()); _paste_count = 0; } @@ -704,7 +704,7 @@ GraphCanvas::copy_selection() void GraphCanvas::paste() { - std::lock_guard lock(_app.world().rdf_mutex()); + const std::lock_guard lock{_app.world().rdf_mutex()}; const Glib::ustring str = Gtk::Clipboard::get()->wait_for_text(); auto parser = _app.loader()->parser(); @@ -888,8 +888,8 @@ GraphCanvas::load_plugin(const std::weak_ptr& weak_plugin) return; } - raul::Symbol symbol = plugin->default_block_symbol(); - unsigned offset = _app.store()->child_name_offset(_graph->path(), symbol); + raul::Symbol symbol = plugin->default_block_symbol(); + const unsigned offset = _app.store()->child_name_offset(_graph->path(), symbol); if (offset != 0) { std::stringstream ss; ss << symbol << "_" << offset; diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp index 53defd75..0abd086e 100644 --- a/src/gui/GraphTreeWindow.cpp +++ b/src/gui/GraphTreeWindow.cpp @@ -159,7 +159,7 @@ GraphTreeWindow::find_graph(Gtk::TreeModel::Children root, const std::shared_ptr& graph) { for (auto c = root.begin(); c != root.end(); ++c) { - std::shared_ptr pm = (*c)[_graph_tree_columns.graph_model_col]; + const std::shared_ptr pm = (*c)[_graph_tree_columns.graph_model_col]; if (graph == pm) { return c; } @@ -198,7 +198,7 @@ GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path, const auto active = _graph_treestore->get_iter(path); auto row = *active; - std::shared_ptr pm = row[_graph_tree_columns.graph_model_col]; + const std::shared_ptr pm = row[_graph_tree_columns.graph_model_col]; _app->window_factory()->present_graph(pm); } @@ -206,11 +206,11 @@ GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path, void GraphTreeWindow::event_graph_enabled_toggled(const Glib::ustring& path_str) { - Gtk::TreeModel::Path path(path_str); - auto active = _graph_treestore->get_iter(path); - auto row = *active; + const Gtk::TreeModel::Path path{path_str}; + auto active = _graph_treestore->get_iter(path); + auto row = *active; - std::shared_ptr pm = row[_graph_tree_columns.graph_model_col]; + const std::shared_ptr pm = row[_graph_tree_columns.graph_model_col]; assert(pm); if (_enable_signal) { diff --git a/src/gui/GraphView.cpp b/src/gui/GraphView.cpp index a5ca7dd1..969e0add 100644 --- a/src/gui/GraphView.cpp +++ b/src/gui/GraphView.cpp @@ -120,8 +120,9 @@ GraphView::set_graph(const std::shared_ptr& graph) std::shared_ptr GraphView::create(App& app, const std::shared_ptr& graph) { - GraphView* result = nullptr; - Glib::RefPtr xml = WidgetFactory::create("warehouse_win"); + GraphView* result = nullptr; + const Glib::RefPtr xml = + WidgetFactory::create("warehouse_win"); xml->get_widget_derived("graph_view_box", result); if (!result) { diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp index 61796de4..144a2cc4 100644 --- a/src/gui/LoadGraphWindow.cpp +++ b/src/gui/LoadGraphWindow.cpp @@ -198,7 +198,7 @@ LoadGraphWindow::ok_clicked() true, FilePath(get_filename()), parent, symbol, _initial_data); } else { - std::list uri_list = get_filenames(); + const std::list uri_list = get_filenames(); for (const auto& u : uri_list) { // Cascade Atom& x = _initial_data.find(uris.ingen_canvasX)->second; @@ -244,7 +244,7 @@ LoadGraphWindow::symbol_from_filename(const Glib::ustring& filename) raul::Symbol LoadGraphWindow::avoid_symbol_clash(const raul::Symbol& symbol) { - unsigned offset = _app->store()->child_name_offset( + const unsigned offset = _app->store()->child_name_offset( _graph->path(), symbol); if (offset != 0) { diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index 940f09b1..d0bba637 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -351,7 +351,7 @@ LoadPluginWindow::plugin_activated(const Gtk::TreeModel::Path& path, void LoadPluginWindow::plugin_selection_changed() { - size_t n_selected = _selection->get_selected_rows().size(); + const size_t n_selected = _selection->get_selected_rows().size(); if (n_selected == 0) { _name_offset = 0; _name_entry->set_text(""); @@ -405,7 +405,7 @@ LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter) const URIs& uris = _app->uris(); auto row = *iter; auto plugin = row.get_value(_plugins_columns._col_plugin); - bool polyphonic = _polyphonic_checkbutton->get_active(); + const bool polyphonic = _polyphonic_checkbutton->get_active(); string name = _name_entry->get_text(); if (name.empty()) { @@ -420,8 +420,8 @@ LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter) dialog.run(); } else { - raul::Path path = _graph->path().child(raul::Symbol::symbolify(name)); - Properties props = _initial_data; + const raul::Path path = _graph->path().child(raul::Symbol::symbolify(name)); + Properties props = _initial_data; props.emplace(uris.rdf_type, Property(uris.ingen_Block)); props.emplace(uris.lv2_prototype, _app->forge().make_urid(plugin->uri())); props.emplace(uris.ingen_polyphonic, _app->forge().make(polyphonic)); @@ -457,7 +457,7 @@ LoadPluginWindow::filter_changed() // Get selected criteria const auto row = *(_filter_combo->get_active()); - CriteriaColumns::Criteria criteria = row[_criteria_columns._col_criteria]; + const CriteriaColumns::Criteria criteria = row[_criteria_columns._col_criteria]; string field; diff --git a/src/gui/MessagesWindow.cpp b/src/gui/MessagesWindow.cpp index 7a382d51..db32af91 100644 --- a/src/gui/MessagesWindow.cpp +++ b/src/gui/MessagesWindow.cpp @@ -84,7 +84,7 @@ MessagesWindow::init_window(App& app) void MessagesWindow::post_error(const string& msg) { - Glib::RefPtr text_buf = _textview->get_buffer(); + const Glib::RefPtr text_buf = _textview->get_buffer(); text_buf->insert_with_tag(text_buf->end(), msg, _error_tag); text_buf->insert(text_buf->end(), "\n"); @@ -101,7 +101,7 @@ MessagesWindow::post_error(const string& msg) int MessagesWindow::log(LV2_URID type, const char* fmt, va_list args) { - std::lock_guard lock(_mutex); + const std::lock_guard lock{_mutex}; #if USE_VASPRINTF char* buf = nullptr; @@ -125,7 +125,7 @@ MessagesWindow::flush() std::string line; { - std::lock_guard lock(_mutex); + const std::lock_guard lock{_mutex}; if (!_stream.rdbuf()->in_avail()) { return; } @@ -133,7 +133,7 @@ MessagesWindow::flush() std::getline(_stream, line, '\0'); } - Glib::RefPtr text_buf = _textview->get_buffer(); + const Glib::RefPtr text_buf = _textview->get_buffer(); auto t = _tags.find(type); if (t != _tags.end()) { @@ -151,7 +151,7 @@ MessagesWindow::flush() void MessagesWindow::clear_clicked() { - Glib::RefPtr text_buf = _textview->get_buffer(); + const Glib::RefPtr text_buf = _textview->get_buffer(); text_buf->erase(text_buf->begin(), text_buf->end()); _clear_button->set_sensitive(false); } diff --git a/src/gui/NewSubgraphWindow.cpp b/src/gui/NewSubgraphWindow.cpp index 086159a5..2f7d82f3 100644 --- a/src/gui/NewSubgraphWindow.cpp +++ b/src/gui/NewSubgraphWindow.cpp @@ -93,7 +93,7 @@ NewSubgraphWindow::set_graph(std::shared_ptr graph) void NewSubgraphWindow::name_changed() { - std::string name = _name_entry->get_text(); + const std::string name = _name_entry->get_text(); if (!raul::Symbol::is_valid(name)) { _message_label->set_text("Name contains invalid characters."); _ok_button->property_sensitive() = false; diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index 2ebc223d..8a03d869 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -245,7 +245,7 @@ NodeMenu::on_save_preset_activated() const std::string real_path = Glib::build_filename(dirname, bundle, file); const std::string real_uri = Glib::filename_to_uri(real_path); - Properties props{ + const Properties props{ { _app->uris().rdf_type, _app->uris().pset_Preset }, { _app->uris().rdfs_label, diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 1b090c4f..223c0832 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -207,7 +207,7 @@ NodeModule::show_human_names(bool b) if (name_property.type() == uris.forge.String) { label = name_property.ptr(); } else { - Glib::ustring hn = block()->plugin_model()->port_human_name( + const Glib::ustring hn = block()->plugin_model()->port_human_name( port->model()->index()); if (!hn.empty()) { label = hn; @@ -532,9 +532,10 @@ NodeModule::on_selected(gboolean selected) if (selected && win->documentation_is_visible()) { std::string doc; - bool html = false; #if USE_WEBKIT - html = true; + const bool html = true; +#else + const bool html = false; #endif if (block()->plugin_model()) { doc = block()->plugin_model()->documentation(html); diff --git a/src/gui/PluginMenu.cpp b/src/gui/PluginMenu.cpp index ac3c3981..f8c7dafc 100644 --- a/src/gui/PluginMenu.cpp +++ b/src/gui/PluginMenu.cpp @@ -126,7 +126,7 @@ PluginMenu::build_plugin_class_menu(Gtk::Menu* menu, return 0; } - Gtk::Menu_Helpers::MenuElem menu_elem = Gtk::Menu_Helpers::MenuElem( + const Gtk::Menu_Helpers::MenuElem menu_elem = Gtk::Menu_Helpers::MenuElem( std::string("_") + sub_label_str); menu->items().push_back(menu_elem); Gtk::MenuItem* menu_item = &(menu->items().back()); @@ -134,7 +134,7 @@ PluginMenu::build_plugin_class_menu(Gtk::Menu* menu, Gtk::Menu* submenu = Gtk::manage(new Gtk::Menu()); menu_item->set_submenu(*submenu); - size_t num_child_items = build_plugin_class_menu( + const size_t num_child_items = build_plugin_class_menu( submenu, c, classes, children, ancestors); _class_menus.emplace(sub_uri_str, MenuRecord(menu_item, submenu)); @@ -158,10 +158,10 @@ PluginMenu::add_plugin_to_menu(MenuRecord& menu, LilvNode* ingen_Graph = lilv_new_uri(lworld, uris.ingen_Graph.c_str()); LilvNode* rdf_type = lilv_new_uri(lworld, uris.rdf_type.c_str()); - bool is_graph = lilv_world_ask(lworld, - lilv_plugin_get_uri(p->lilv_plugin()), - rdf_type, - ingen_Graph); + const bool is_graph = lilv_world_ask(lworld, + lilv_plugin_get_uri(p->lilv_plugin()), + rdf_type, + ingen_Graph); menu.menu->items().push_back( Gtk::Menu_Helpers::MenuElem( diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 89b86184..8adf8311 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -265,7 +265,7 @@ Port::build_enum_menu() auto block = std::dynamic_pointer_cast(model()->parent()); Gtk::Menu* menu = Gtk::manage(new Gtk::Menu()); - PluginModel::ScalePoints points = block->plugin_model()->port_scale_points( + const PluginModel::ScalePoints points = block->plugin_model()->port_scale_points( model()->index()); for (const auto& p : points) { menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p.second)); @@ -316,7 +316,7 @@ Port::build_uri_menu() rdfs::classes(world, ranges, false); // Get all objects in range - rdfs::Objects values = rdfs::instances(world, ranges); + const rdfs::Objects values = rdfs::instances(world, ranges); // Add a menu item for each such class for (const auto& v : values) { @@ -553,9 +553,10 @@ Port::on_selected(gboolean b) GraphWindow* win = _app.window_factory()->parent_graph_window(block); if (win && win->documentation_is_visible() && block->plugin_model()) { - bool html = false; #if USE_WEBKIT - html = true; + const bool html = true; +#else + const bool html = false; #endif const std::string& doc = block->plugin_model()->port_documentation( pm->index(), html); diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index 4ea1536d..b51ae37e 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -382,9 +382,9 @@ PropertiesWindow::create_value_widget(const URI& key, ? world.uri_map().unmap_uri(value.get()) : ""); - LilvNode* pred = lilv_new_uri(lworld, key.c_str()); - URISet ranges = rdfs::range(world, pred, true); - URIEntry* widget = manage(new URIEntry(_app, ranges, str ? str : "")); + LilvNode* pred = lilv_new_uri(lworld, key.c_str()); + const URISet ranges = rdfs::range(world, pred, true); + URIEntry* widget = manage(new URIEntry(_app, ranges, str ? str : "")); widget->signal_changed().connect( sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key)); lilv_node_free(pred); @@ -400,10 +400,10 @@ PropertiesWindow::create_value_widget(const URI& key, if (type == _app->uris().atom_URI || type == _app->uris().rdfs_Class || is_class) { - LilvNode* pred = lilv_new_uri(lworld, key.c_str()); - URISet ranges = rdfs::range(world, pred, true); - const char* str = value.is_valid() ? value.ptr() : ""; - URIEntry* widget = manage(new URIEntry(_app, ranges, str)); + LilvNode* pred = lilv_new_uri(lworld, key.c_str()); + const URISet ranges = rdfs::range(world, pred, true); + const char* str = value.is_valid() ? value.ptr() : ""; + URIEntry* widget = manage(new URIEntry(_app, ranges, str)); widget->signal_changed().connect( sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key)); lilv_node_free(pred); @@ -482,7 +482,7 @@ PropertiesWindow::remove_property(const URI& key, const Atom& value) Atom PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget) { - Forge& forge = _app->forge(); + const Forge& forge = _app->forge(); if (type == forge.Int) { auto* spin = dynamic_cast(value_widget); @@ -542,7 +542,7 @@ PropertiesWindow::active_key() const return ""; } - Glib::ustring prop_uri = (*iter)[_combo_columns.uri_col]; + const Glib::ustring prop_uri = (*iter)[_combo_columns.uri_col]; return prop_uri; } diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp index bba8c31f..64aa893b 100644 --- a/src/gui/RDFS.cpp +++ b/src/gui/RDFS.cpp @@ -77,7 +77,7 @@ closure(World& world, const LilvNode* pred, URISet& types, bool super) LILV_FOREACH (nodes, m, matches) { const LilvNode* klass_node = lilv_nodes_get(matches, m); if (lilv_node_is_uri(klass_node)) { - URI klass(lilv_node_as_uri(klass_node)); + const URI klass{lilv_node_as_uri(klass_node)}; if (!types.count(klass)) { ++added; klasses.insert(klass); @@ -144,8 +144,8 @@ URISet properties(World& world, const std::shared_ptr& model) { - URISet properties; - URISet types = rdfs::types(world, model); + URISet properties; + const URISet types = rdfs::types(world, model); LilvNode* rdf_type = lilv_new_uri(world.lilv_world(), LILV_NS_RDF "type"); diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp index 0e5f1b01..d61bbb31 100644 --- a/src/gui/ThreadedLoader.cpp +++ b/src/gui/ThreadedLoader.cpp @@ -74,7 +74,7 @@ void ThreadedLoader::run() { while (_sem.wait() && !_exit_flag) { - std::lock_guard lock(_mutex); + const std::lock_guard lock{_mutex}; while (!_events.empty()) { _events.front()(); _events.pop_front(); @@ -89,7 +89,7 @@ ThreadedLoader::load_graph(bool merge, const std::optional& engine_symbol, const std::optional& engine_data) { - std::lock_guard lock(_mutex); + const std::lock_guard lock{_mutex}; Glib::ustring engine_base = ""; if (engine_parent) { @@ -117,7 +117,7 @@ ThreadedLoader::load_graph_event( const std::optional& engine_symbol, const std::optional& engine_data) { - std::lock_guard lock(_app.world().rdf_mutex()); + const std::lock_guard lock{_app.world().rdf_mutex()}; _app.world().parser()->parse_file(_app.world(), *_app.world().interface(), @@ -132,7 +132,7 @@ ThreadedLoader::save_graph( const std::shared_ptr& model, const URI& uri) { - std::lock_guard lock(_mutex); + const std::lock_guard lock{_mutex}; _events.emplace_back(sigc::hide_return( sigc::bind(sigc::mem_fun(this, &ThreadedLoader::save_graph_event), @@ -149,7 +149,7 @@ ThreadedLoader::save_graph_event( { assert(uri.scheme() == "file"); if (_app.serialiser()) { - std::lock_guard lock(_app.world().rdf_mutex()); + const std::lock_guard lock{_app.world().rdf_mutex()}; if (uri.string().find(".ingen") != std::string::npos) { _app.serialiser()->write_bundle(model, uri); diff --git a/src/gui/URIEntry.cpp b/src/gui/URIEntry.cpp index d701e3a2..c9ef66cb 100644 --- a/src/gui/URIEntry.cpp +++ b/src/gui/URIEntry.cpp @@ -66,7 +66,7 @@ URIEntry::build_value_menu() LilvNode* rdfs_Datatype = lilv_new_uri(lworld, LILV_NS_RDFS "Datatype"); LilvNode* rdfs_subClassOf = lilv_new_uri(lworld, LILV_NS_RDFS "subClassOf"); - rdfs::Objects values = rdfs::instances(world, _types); + const rdfs::Objects values = rdfs::instances(world, _types); for (const auto& v : values) { const LilvNode* inst = lilv_new_uri(lworld, v.second.c_str()); diff --git a/src/gui/ingen_gui.cpp b/src/gui/ingen_gui.cpp index 4c33c514..8ddacb04 100644 --- a/src/gui/ingen_gui.cpp +++ b/src/gui/ingen_gui.cpp @@ -35,7 +35,7 @@ struct GUIModule : public Module { using SigClientInterface = client::SigClientInterface; void load(World& world) override { - URI uri(world.conf().option("connect").ptr()); + const URI uri{world.conf().option("connect").ptr()}; if (!world.interface()) { world.set_interface( world.new_interface(URI(uri), make_client(world))); diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp index 8f1233e1..a20689ea 100644 --- a/src/ingen/ingen.cpp +++ b/src/ingen/ingen.cpp @@ -203,7 +203,7 @@ run(int argc, char** argv) engine_interface->get(URI("ingen:/plugins")); engine_interface->get(main_uri()); - std::lock_guard lock(world->rdf_mutex()); + const std::lock_guard lock{world->rdf_mutex()}; world->parser()->parse_file( *world, *engine_interface, graph, parent, symbol); } else if (conf.option("server-load").is_valid()) { diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp index 3fa7a1c3..cae6b252 100644 --- a/src/server/BlockImpl.cpp +++ b/src/server/BlockImpl.cpp @@ -200,7 +200,7 @@ BlockImpl::bypass(RunContext& ctx) } // Dumb bypass - for (PortType t : { PortType::AUDIO, PortType::CV, PortType::ATOM }) { + for (const PortType t : { PortType::AUDIO, PortType::CV, PortType::ATOM }) { for (uint32_t i = 0;; ++i) { PortImpl* in = nth_port_by_type(i, true, t); PortImpl* out = nth_port_by_type(i, false, t); diff --git a/src/server/Broadcaster.cpp b/src/server/Broadcaster.cpp index 1d5cc843..e7406dc6 100644 --- a/src/server/Broadcaster.cpp +++ b/src/server/Broadcaster.cpp @@ -29,7 +29,7 @@ namespace ingen::server { Broadcaster::~Broadcaster() { - std::lock_guard lock(_clients_mutex); + const std::lock_guard lock{_clients_mutex}; _clients.clear(); _broadcastees.clear(); } @@ -39,7 +39,7 @@ Broadcaster::~Broadcaster() void Broadcaster::register_client(const std::shared_ptr& client) { - std::lock_guard lock(_clients_mutex); + const std::lock_guard lock{_clients_mutex}; _clients.insert(client); } @@ -50,7 +50,7 @@ Broadcaster::register_client(const std::shared_ptr& client) bool Broadcaster::unregister_client(const std::shared_ptr& client) { - std::lock_guard lock(_clients_mutex); + const std::lock_guard lock{_clients_mutex}; const size_t erased = _clients.erase(client); _broadcastees.erase(client); return (erased > 0); @@ -71,7 +71,7 @@ Broadcaster::set_broadcast(const std::shared_ptr& client, void Broadcaster::send_plugins(const BlockFactory::Plugins& plugins) { - std::lock_guard lock(_clients_mutex); + const std::lock_guard lock{_clients_mutex}; for (const auto& c : _clients) { send_plugins_to(c.get(), plugins); } diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp index b453932b..3b023258 100644 --- a/src/server/CompiledGraph.cpp +++ b/src/server/CompiledGraph.cpp @@ -161,7 +161,7 @@ CompiledGraph::compile_graph(GraphImpl* graph) _master = Task::simplify(std::move(_master)); if (graph->engine().world().conf().option("trace").get()) { - ColorContext ctx(stderr, ColorContext::Color::YELLOW); + const ColorContext ctx{stderr, ColorContext::Color::YELLOW}; dump(graph->path()); } } diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 265333d4..e8dd3554 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -198,8 +198,9 @@ ControlBindings::port_value_changed(RunContext& ctx, { const ingen::URIs& uris = ctx.engine().world().uris(); if (!!key) { - int16_t value = port_value_to_control( - ctx, port, key.type, value_atom); + const int16_t value = + port_value_to_control(ctx, port, key.type, value_atom); + uint16_t size = 0; uint8_t buf[4]; switch (key.type) { @@ -390,7 +391,7 @@ ControlBindings::set_port_value(RunContext& ctx, // TODO: Set port value property so it is saved port->set_control_value(ctx, ctx.start(), val); - URIs& uris = ctx.engine().world().uris(); + const URIs& uris = ctx.engine().world().uris(); ctx.notify(uris.ingen_value, ctx.start(), port, sizeof(float), _forge.Float, &val); } diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 6dac1eec..5a1ee2ec 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -349,7 +349,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) LILV_FOREACH (nodes, i, sizes) { const LilvNode* d = lilv_nodes_get(sizes, i); if (lilv_node_is_int(d)) { - uint32_t size_val = lilv_node_as_int(d); + const uint32_t size_val = lilv_node_as_int(d); port_buffer_size = std::max(port_buffer_size, size_val); } } @@ -481,7 +481,7 @@ LV2Block::save_state(const FilePath& dir) const World& world = _lv2_plugin->world(); LilvWorld* lworld = world.lilv_world(); - StatePtr state{ + const StatePtr state{ lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(), const_cast(this)->instance(0), &world.uri_map().urid_map(), @@ -521,7 +521,7 @@ LV2Block::duplicate(Engine& engine, const SampleRate rate = engine.sample_rate(); // Get current state - StatePtr state{ + const StatePtr state{ lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(), instance(0), &engine.world().uri_map().urid_map(), @@ -589,10 +589,10 @@ LV2_Worker_Status LV2Block::work(uint32_t size, const void* data) { if (_worker_iface) { - std::lock_guard lock(_work_mutex); + const std::lock_guard lock{_work_mutex}; - LV2_Handle inst = lilv_instance_get_handle(instance(0)); - LV2_Worker_Status st = _worker_iface->work(inst, work_respond, this, size, data); + LV2_Handle inst = lilv_instance_get_handle(instance(0)); + const LV2_Worker_Status st = _worker_iface->work(inst, work_respond, this, size, data); if (st) { parent_graph()->engine().log().error( "Error calling %1% work method\n", _path); @@ -717,17 +717,17 @@ LV2Block::save_preset(const URI& uri, const FilePath dirname = path.parent_path(); const FilePath basename = path.stem(); - StatePtr state{lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(), - instance(0), - lmap, - nullptr, - nullptr, - nullptr, - path.c_str(), - get_port_value, - this, - LV2_STATE_IS_NATIVE, - nullptr)}; + const StatePtr state{lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(), + instance(0), + lmap, + nullptr, + nullptr, + nullptr, + path.c_str(), + get_port_value, + this, + LV2_STATE_IS_NATIVE, + nullptr)}; if (state) { const auto l = props.find(_uris.rdfs_label); diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp index 25ae9294..fdf9f2e6 100644 --- a/src/server/LV2Plugin.cpp +++ b/src/server/LV2Plugin.cpp @@ -73,7 +73,7 @@ LV2Plugin::symbol() const } while (working.length() > 0) { - size_t last_slash = working.find_last_of('/'); + const size_t last_slash = working.find_last_of('/'); const std::string symbol = working.substr(last_slash+1); if ( (symbol[0] >= 'a' && symbol[0] <= 'z') || (symbol[0] >= 'A' && symbol[0] <= 'Z') ) { diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 307d9b73..fa061640 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -289,9 +289,9 @@ PortImpl::set_voice_value(const RunContext& ctx, void PortImpl::update_set_state(const RunContext& ctx, uint32_t v) { - Voice& voice = _voices->at(v); - SetState& state = voice.set_state; - BufferRef buf = voice.buffer; + Voice& voice = _voices->at(v); + SetState& state = voice.set_state; + const BufferRef buf = voice.buffer; switch (state.state) { case SetState::State::SET: break; @@ -458,10 +458,10 @@ PortImpl::monitor(RunContext& ctx, bool send_now) return; } - Forge& forge = ctx.engine().world().forge(); - URIs& uris = ctx.engine().world().uris(); - LV2_URID key = 0; - float val = 0.0f; + const Forge& forge = ctx.engine().world().forge(); + const URIs& uris = ctx.engine().world().uris(); + LV2_URID key = 0; + float val = 0.0f; switch (_type.id()) { case PortType::UNKNOWN: break; diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp index 5d719761..74550a3e 100644 --- a/src/server/PreProcessor.cpp +++ b/src/server/PreProcessor.cpp @@ -55,7 +55,7 @@ PreProcessor::event(Event* const ev, Event::Mode mode) { // TODO: Probably possible to make this lock-free with CAS ThreadManager::assert_not_thread(THREAD_IS_REAL_TIME); - std::lock_guard lock(_mutex); + const std::lock_guard lock{_mutex}; assert(!ev->is_prepared()); assert(!ev->next()); @@ -140,7 +140,7 @@ PreProcessor::process(RunContext& ctx, PostProcessor& dest, size_t limit) if (n_processed > 0) { #ifndef NDEBUG - Engine& engine = ctx.engine(); + const Engine& engine = ctx.engine(); if (engine.world().conf().option("trace").get()) { const uint64_t start = engine.cycle_start_time(ctx); const uint64_t end = engine.current_time(); diff --git a/src/server/RunContext.cpp b/src/server/RunContext.cpp index 2bac3140..95d68f57 100644 --- a/src/server/RunContext.cpp +++ b/src/server/RunContext.cpp @@ -160,9 +160,9 @@ void 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{}; + const pthread_t pthread = _thread->native_handle(); + const int policy = (priority > 0) ? SCHED_FIFO : SCHED_OTHER; + sched_param sp{}; sp.sched_priority = (priority > 0) ? priority : 0; if (pthread_setschedparam(pthread, policy, &sp)) { _engine.log().error( diff --git a/src/server/UndoStack.cpp b/src/server/UndoStack.cpp index 395a04cd..c8ce7d69 100644 --- a/src/server/UndoStack.cpp +++ b/src/server/UndoStack.cpp @@ -41,7 +41,7 @@ UndoStack::start_entry() if (_depth == 0) { time_t now = {}; time(&now); - _stack.emplace_back(Entry(now)); + _stack.emplace_back(now); } return ++_depth; } @@ -188,8 +188,8 @@ UndoStack::write_entry(Sratom* sratom, strftime(time_str, sizeof(time_str), "%FT%T", gmtime(&entry.time)); // entry rdf:type ingen:UndoEntry - SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "time")); - SerdNode o = serd_node_from_string(SERD_LITERAL, USTR(time_str)); + SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "time")); + const SerdNode o = serd_node_from_string(SERD_LITERAL, USTR(time_str)); serd_writer_write_statement(writer, SERD_ANON_CONT, nullptr, subject, &p, &o, nullptr, nullptr); p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "events")); @@ -245,8 +245,8 @@ UndoStack::save(FILE* stream, const char* name) reinterpret_cast(serd_writer_end_anon), writer); - SerdNode s = serd_node_from_string(SERD_BLANK, USTR(name)); - SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "entries")); + const SerdNode s = serd_node_from_string(SERD_BLANK, USTR(name)); + const SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "entries")); BlankIDs ids('u'); ListContext ctx(ids, 0, &s, &p); diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp index 5b4da498..c58fe89e 100644 --- a/src/server/Worker.cpp +++ b/src/server/Worker.cpp @@ -46,8 +46,8 @@ schedule(LV2_Worker_Schedule_Handle handle, uint32_t size, const void* data) { - auto* block = static_cast(handle); - Engine& engine = block->parent_graph()->engine(); + auto* block = static_cast(handle); + const Engine& engine = block->parent_graph()->engine(); return engine.worker()->request(block, size, data); } @@ -57,8 +57,8 @@ schedule_sync(LV2_Worker_Schedule_Handle handle, uint32_t size, const void* data) { - auto* block = static_cast(handle); - Engine& engine = block->parent_graph()->engine(); + auto* block = static_cast(handle); + const Engine& engine = block->parent_graph()->engine(); return engine.sync_worker()->request(block, size, data); } @@ -72,7 +72,7 @@ Worker::request(LV2Block* block, return block->work(size, data); } - Engine& engine = block->parent_graph()->engine(); + const Engine& engine = block->parent_graph()->engine(); if (_requests.write_space() < sizeof(MessageHeader) + size) { engine.log().error("Work request ring overflow\n"); return LV2_WORKER_ERR_NO_SPACE; diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index 44c734a8..115d3e9c 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -57,7 +57,7 @@ Connect::~Connect() = default; bool Connect::pre_process(PreProcessContext& ctx) { - std::lock_guard lock(_engine.store()->mutex()); + const std::lock_guard lock{_engine.store()->mutex()}; Node* tail = _engine.store()->get(_msg.tail); if (!tail) { @@ -173,7 +173,7 @@ Connect::execute(RunContext& ctx) void Connect::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); if (!_tail_remove.empty() || !_tail_add.empty()) { diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp index f6bcc62a..24e7b339 100644 --- a/src/server/events/Copy.cpp +++ b/src/server/events/Copy.cpp @@ -57,7 +57,7 @@ Copy::~Copy() = default; bool Copy::pre_process(PreProcessContext& ctx) { - std::lock_guard lock(_engine.store()->mutex()); + const std::lock_guard lock{_engine.store()->mutex()}; if (uri_is_path(_msg.old_uri)) { // Old URI is a path within the engine @@ -163,7 +163,7 @@ Copy::engine_to_filesystem(PreProcessContext&) return Event::pre_process_done(Status::INTERNAL_ERROR); } - std::lock_guard lock(_engine.world().rdf_mutex()); + const std::lock_guard lock{_engine.world().rdf_mutex()}; if (ends_with(_msg.new_uri, ".ingen") || ends_with(_msg.new_uri, ".ingen/")) { _engine.world().serialiser()->write_bundle(graph, URI(_msg.new_uri)); @@ -184,7 +184,7 @@ Copy::filesystem_to_engine(PreProcessContext&) return Event::pre_process_done(Status::INTERNAL_ERROR); } - std::lock_guard lock(_engine.world().rdf_mutex()); + const std::lock_guard lock{_engine.world().rdf_mutex()}; // Old URI is a filesystem path and new URI is a path within the engine const std::string src_path(_msg.old_uri.path()); @@ -214,7 +214,7 @@ Copy::execute(RunContext&) void Copy::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); } diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index 73834fcb..aa4cb1c0 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -187,7 +187,7 @@ CreateBlock::execute(RunContext&) void CreateBlock::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _update.send(*_engine.broadcaster()); } diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp index bcc935bb..8864c1df 100644 --- a/src/server/events/CreateGraph.cpp +++ b/src/server/events/CreateGraph.cpp @@ -235,7 +235,7 @@ CreateGraph::execute(RunContext& ctx) void CreateGraph::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _update.send(*_engine.broadcaster()); } diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 7a01d0d9..937842a7 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -210,7 +210,7 @@ CreatePort::execute(RunContext& ctx) void CreatePort::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->put(path_to_uri(_path), _update); } diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index b64c81c0..192b0584 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -104,7 +104,7 @@ Delete::pre_process(PreProcessContext& ctx) } // Take a writer lock while we modify the store - std::lock_guard lock(_engine.store()->mutex()); + const std::lock_guard lock{_engine.store()->mutex()}; _engine.store()->remove(iter, _removed_objects); @@ -189,7 +189,7 @@ Delete::execute(RunContext& ctx) void Delete::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS && (_block || _port)) { if (_block) { _block->deactivate(); diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 0b8cab39..1c972f1d 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -213,7 +213,7 @@ Delta::pre_process(PreProcessContext& ctx) return Event::pre_process_done(Status::FAILURE); } - std::lock_guard lock(_engine.store()->mutex()); + const std::lock_guard lock{_engine.store()->mutex()}; _object = is_graph_object ? static_cast(_engine.store()->get(uri_to_path(_subject))) @@ -225,7 +225,7 @@ Delta::pre_process(PreProcessContext& ctx) } if (is_graph_object && !_object) { - raul::Path path(uri_to_path(_subject)); + const raul::Path path{uri_to_path(_subject)}; bool is_graph = false; bool is_block = false; @@ -594,7 +594,7 @@ Delta::post_process() _state.reset(); } - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (_create_event) { _create_event->post_process(); diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index ef0cbd0b..4b4bbfe9 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -117,7 +117,7 @@ Disconnect::Impl::Impl(Engine& e, bool Disconnect::pre_process(PreProcessContext& ctx) { - std::lock_guard lock(_engine.store()->mutex()); + const std::lock_guard lock{_engine.store()->mutex()}; if (_msg.tail.parent().parent() != _msg.head.parent().parent() && _msg.tail.parent() != _msg.head.parent().parent() @@ -219,7 +219,7 @@ Disconnect::execute(RunContext& ctx) void Disconnect::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); } diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index 957c6a6f..296d6ddd 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -156,7 +156,7 @@ DisconnectAll::execute(RunContext& ctx) void DisconnectAll::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); } diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index f4cbb49d..9efef123 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -50,7 +50,7 @@ Get::Get(Engine& engine, bool Get::pre_process(PreProcessContext&) { - std::lock_guard lock(_engine.store()->mutex()); + const std::lock_guard lock{_engine.store()->mutex()}; const auto& uri = _msg.subject; if (uri == "ingen:/plugins") { @@ -96,7 +96,7 @@ Get::execute(RunContext&) void Get::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS && _request_client) { if (_msg.subject == "ingen:/plugins") { _engine.broadcaster()->send_plugins_to(_request_client.get(), _plugins); diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp index ea05d34c..3af0ce6c 100644 --- a/src/server/events/Move.cpp +++ b/src/server/events/Move.cpp @@ -46,7 +46,7 @@ Move::Move(Engine& engine, bool Move::pre_process(PreProcessContext&) { - std::lock_guard lock(_engine.store()->mutex()); + const std::lock_guard lock{_engine.store()->mutex()}; if (!_msg.old_path.parent().is_parent_of(_msg.new_path)) { return Event::pre_process_done(Status::PARENT_DIFFERS, _msg.new_path); @@ -78,7 +78,7 @@ Move::execute(RunContext&) void Move::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); } diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index 8b599354..04da7338 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -54,7 +54,7 @@ SetPortValue::SetPortValue(Engine& engine, bool SetPortValue::pre_process(PreProcessContext&) { - ingen::URIs& uris = _engine.world().uris(); + const ingen::URIs& uris = _engine.world().uris(); if (_port->is_output()) { return Event::pre_process_done(Status::DIRECTION_MISMATCH, _port->path()); } @@ -92,8 +92,8 @@ SetPortValue::apply(RunContext& ctx) return; } - ingen::URIs& uris = _engine.world().uris(); - Buffer* buf = _port->buffer(0).get(); + const ingen::URIs& uris = _engine.world().uris(); + Buffer* buf = _port->buffer(0).get(); if (_buffer) { if (_port->user_buffer(ctx)) { @@ -127,7 +127,7 @@ SetPortValue::apply(RunContext& ctx) void SetPortValue::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS && !_activity) { _engine.broadcaster()->set_property( _port->uri(), diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 851a83fb..f253ee9b 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -512,7 +512,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor, nullptr, true); - Lib::Graphs graphs = find_graphs(URI(reinterpret_cast(manifest_node.buf))); + const Lib::Graphs graphs = find_graphs(URI(reinterpret_cast(manifest_node.buf))); serd_node_free(&manifest_node); const LV2Graph* graph = nullptr; @@ -533,11 +533,11 @@ ingen_instantiate(const LV2_Descriptor* descriptor, plugin->world = std::make_unique(map, unmap, log); plugin->world->load_configuration(plugin->argc, plugin->argv); - LV2_URID bufsz_max = map->map(map->handle, LV2_BUF_SIZE__maxBlockLength); - LV2_URID bufsz_seq = map->map(map->handle, LV2_BUF_SIZE__sequenceSize); - LV2_URID atom_Int = map->map(map->handle, LV2_ATOM__Int); - int32_t block_length = 0; - int32_t seq_size = 0; + const LV2_URID bufsz_max = map->map(map->handle, LV2_BUF_SIZE__maxBlockLength); + const LV2_URID bufsz_seq = map->map(map->handle, LV2_BUF_SIZE__sequenceSize); + const LV2_URID atom_Int = map->map(map->handle, LV2_ATOM__Int); + int32_t block_length = 0; + int32_t seq_size = 0; if (options) { for (const LV2_Options_Option* o = options; o->key; ++o) { if (o->key == bufsz_max && o->type == atom_Int) { @@ -567,7 +567,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor, plugin->engine = engine; plugin->world->set_engine(engine); - std::shared_ptr interface = engine->interface(); + const std::shared_ptr interface = engine->interface(); plugin->world->set_interface(interface); @@ -580,7 +580,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor, engine->activate(); ThreadManager::single_threaded = true; - std::lock_guard lock(plugin->world->rdf_mutex()); + const std::lock_guard lock{plugin->world->rdf_mutex()}; // Locate to time 0 to process initialization events engine->locate(0, block_length); @@ -602,7 +602,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor, /* Register client after loading graph so the to-ui ring does not overflow. Since we are not yet rolling, it won't be drained, causing a deadlock. */ - std::shared_ptr client(&driver->writer(), NullDeleter); + const std::shared_ptr client{&driver->writer(), NullDeleter}; interface->set_respondee(client); engine->register_client(client); @@ -703,9 +703,9 @@ ingen_save(LV2_Handle instance, return LV2_STATE_ERR_NO_FEATURE; } - LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file); - LV2_URID atom_Path = plugin->map->map(plugin->map->handle, - LV2_ATOM__Path); + const LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file); + const LV2_URID atom_Path = plugin->map->map(plugin->map->handle, + LV2_ATOM__Path); char* real_path = make_path->path(make_path->handle, "main.ttl"); char* state_path = map_path->abstract_path(map_path->handle, real_path); @@ -713,7 +713,7 @@ ingen_save(LV2_Handle instance, auto root = plugin->world->store()->find(raul::Path("/")); { - std::lock_guard lock(plugin->world->rdf_mutex()); + const std::lock_guard lock{plugin->world->rdf_mutex()}; plugin->world->serialiser()->start_to_file( root->second->path(), FilePath{real_path}); @@ -749,10 +749,10 @@ ingen_restore(LV2_Handle instance, return LV2_STATE_ERR_NO_FEATURE; } - LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file); - size_t size = 0; - uint32_t type = 0; - uint32_t valflags = 0; + const LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file); + size_t size = 0; + uint32_t type = 0; + uint32_t valflags = 0; // Get abstract path to graph file const char* path = static_cast( @@ -784,7 +784,7 @@ ingen_restore(LV2_Handle instance, #endif // Load new graph - std::lock_guard lock(plugin->world->rdf_mutex()); + const std::lock_guard lock{plugin->world->rdf_mutex()}; plugin->world->parser()->parse_file( *plugin->world, *plugin->world->interface(), real_path); diff --git a/src/server/internals/Time.cpp b/src/server/internals/Time.cpp index ee97ac84..0768285a 100644 --- a/src/server/internals/Time.cpp +++ b/src/server/internals/Time.cpp @@ -72,8 +72,8 @@ TimeNode::TimeNode(InternalPlugin* plugin, void TimeNode::run(RunContext& ctx) { - BufferRef buf = _notify_port->buffer(0); - auto* seq = buf->get(); + const BufferRef buf = _notify_port->buffer(0); + auto* const seq = buf->get(); // Initialise output to the empty sequence seq->atom.type = _notify_port->bufs().uris().atom_Sequence; diff --git a/tests/ingen_bench.cpp b/tests/ingen_bench.cpp index c7eb336c..d840eea9 100644 --- a/tests/ingen_bench.cpp +++ b/tests/ingen_bench.cpp @@ -115,10 +115,10 @@ run(int argc, char** argv) // Run benchmark // TODO: Set up real-time scheduling for this and worker threads - ingen::Clock clock; - const uint32_t n_test_frames = 1 << 20; - const uint32_t block_length = 4096; - const uint64_t t_start = clock.now_microseconds(); + const ingen::Clock clock; + const uint32_t n_test_frames = 1 << 20; + const uint32_t block_length = 4096; + const uint64_t t_start = clock.now_microseconds(); for (uint32_t i = 0; i < n_test_frames; i += block_length) { world->engine()->advance(block_length); world->engine()->run(block_length); @@ -127,8 +127,8 @@ run(int argc, char** argv) const uint64_t t_end = clock.now_microseconds(); // Write log output - std::unique_ptr log{fopen(out_file.c_str(), "a"), - &fclose}; + const std::unique_ptr log{fopen(out_file.c_str(), "a"), + &fclose}; if (ftell(log.get()) == 0) { fprintf(log.get(), "# n_threads\trun_time\treal_time\n"); } diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp index ec89c40c..ca026e4a 100644 --- a/tests/ingen_test.cpp +++ b/tests/ingen_test.cpp @@ -67,8 +67,8 @@ ingen_try(bool cond, const char* msg) FilePath real_file_path(const char* path) { - std::unique_ptr> real_path{realpath(path, nullptr), - FreeDeleter{}}; + const std::unique_ptr> real_path{realpath(path, nullptr), + FreeDeleter{}}; return FilePath{real_path.get()}; } @@ -146,7 +146,7 @@ run(int argc, char** argv) *world->interface()); // AtomWriter to serialise responses from the engine - std::shared_ptr client(new TestClient(world->log())); + const std::shared_ptr client{new TestClient(world->log())}; world->interface()->set_respondee(client); world->engine()->register_client(client); @@ -162,10 +162,10 @@ run(int argc, char** argv) SerdEnv* env = serd_env_new(&cmds_file_uri); cmds->load_file(env, SERD_TURTLE, run_path); - Sord::Node nil; - int n_events = 0; + const Sord::Node nil; + int n_events = 0; for (;; ++n_events) { - std::string subject_str = fmt("msg%1%", n_events); + const std::string subject_str = fmt("msg%1%", n_events); Sord::URI subject(*world->rdf_world(), subject_str, -- cgit v1.2.1