summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-09-27 18:35:31 -0400
committerDavid Robillard <d@drobilla.net>2022-09-27 18:36:33 -0400
commit92cf4f1e48a90d8622f237a732b08487e0cde46c (patch)
tree9b9cdeeb50b14bf8d64e2c6e914573303a7cc61c
parent3ae3c86937c7ffc45d24e36a33560cd63ebb900b (diff)
downloadingen-92cf4f1e48a90d8622f237a732b08487e0cde46c.tar.gz
ingen-92cf4f1e48a90d8622f237a732b08487e0cde46c.tar.bz2
ingen-92cf4f1e48a90d8622f237a732b08487e0cde46c.zip
Use braced init lists to avoid repeating return types
-rw-r--r--.clang-tidy1
-rw-r--r--include/ingen/Forge.hpp24
-rw-r--r--include/ingen/URI.hpp4
-rw-r--r--include/ingen/URIMap.hpp3
-rw-r--r--include/ingen/filesystem.hpp2
-rw-r--r--src/AtomReader.cpp6
-rw-r--r--src/FilePath.cpp2
-rw-r--r--src/Forge.cpp2
-rw-r--r--src/Log.cpp2
-rw-r--r--src/Parser.cpp12
-rw-r--r--src/URI.cpp2
-rw-r--r--src/gui/PropertiesWindow.cpp2
-rw-r--r--src/runtime_paths.cpp8
-rw-r--r--src/server/BlockImpl.hpp2
-rw-r--r--src/server/BufferFactory.cpp8
-rw-r--r--src/server/LV2Block.cpp2
-rw-r--r--src/server/LV2Options.hpp2
-rw-r--r--src/server/SocketListener.cpp4
-rw-r--r--src/server/Worker.cpp2
19 files changed, 44 insertions, 46 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 01ee20da..675fcd52 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -21,7 +21,6 @@ Checks: >
-misc-unused-parameters,
-modernize-concat-nested-namespaces,
-modernize-pass-by-value,
- -modernize-return-braced-init-list,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-identifier-length,
diff --git a/include/ingen/Forge.hpp b/include/ingen/Forge.hpp
index 8dc7805c..fdd53276 100644
--- a/include/ingen/Forge.hpp
+++ b/include/ingen/Forge.hpp
@@ -44,38 +44,38 @@ public:
return atom.type() == URI || atom.type() == URID;
}
- static Atom make() { return Atom(); }
- Atom make(int32_t v) { return Atom(sizeof(v), Int, &v); }
- Atom make(float v) { return Atom(sizeof(v), Float, &v); }
+ static Atom make() { return {}; }
+ Atom make(int32_t v) { return {sizeof(v), Int, &v}; }
+ Atom make(float v) { return {sizeof(v), Float, &v}; }
Atom make(bool v) {
const int32_t iv = v ? 1 : 0;
- return Atom(sizeof(int32_t), Bool, &iv);
+ return {sizeof(int32_t), Bool, &iv};
}
- Atom make_urid(int32_t v) { return Atom(sizeof(int32_t), URID, &v); }
+ Atom make_urid(int32_t v) { return {sizeof(int32_t), URID, &v}; }
Atom make_urid(const ingen::URI& u);
static Atom alloc(uint32_t s, uint32_t t, const void* v) {
- return Atom(s, t, v);
+ return {s, t, v};
}
Atom alloc(const char* v) {
- const size_t len = strlen(v);
- return Atom(len + 1, String, v);
+ const auto len = static_cast<uint32_t>(strlen(v));
+ return {len + 1U, String, v};
}
Atom alloc(const std::string& v) {
- return Atom(v.length() + 1, String, v.c_str());
+ return {static_cast<uint32_t>(v.length()) + 1U, String, v.c_str()};
}
Atom alloc_uri(const char* v) {
- const size_t len = strlen(v);
- return Atom(len + 1, URI, v);
+ const auto len = static_cast<uint32_t>(strlen(v));
+ return {len + 1U, URI, v};
}
Atom alloc_uri(const std::string& v) {
- return Atom(v.length() + 1, URI, v.c_str());
+ return {static_cast<uint32_t>(v.length()) + 1U, URI, v.c_str()};
}
private:
diff --git a/include/ingen/URI.hpp b/include/ingen/URI.hpp
index ea57edca..0c8d23ef 100644
--- a/include/ingen/URI.hpp
+++ b/include/ingen/URI.hpp
@@ -57,7 +57,7 @@ public:
bool empty() const { return !_node.buf; }
- std::string string() const { return std::string(c_str(), _node.n_bytes); }
+ std::string string() const { return {c_str(), _node.n_bytes}; }
size_t length() const { return _node.n_bytes; }
const char* c_str() const
@@ -102,7 +102,7 @@ private:
URI(SerdNode node, SerdURI uri);
static Chunk make_chunk(const SerdChunk& chunk) {
- return Chunk(reinterpret_cast<const char*>(chunk.buf), chunk.len);
+ return {reinterpret_cast<const char*>(chunk.buf), chunk.len};
}
SerdURI _uri;
diff --git a/include/ingen/URIMap.hpp b/include/ingen/URIMap.hpp
index f5ae8a37..de137af2 100644
--- a/include/ingen/URIMap.hpp
+++ b/include/ingen/URIMap.hpp
@@ -58,8 +58,7 @@ public:
std::shared_ptr<LV2_Feature> feature(World&, Node*) override
{
- return std::shared_ptr<LV2_Feature>(&_feature,
- NullDeleter<LV2_Feature>);
+ return {&_feature, NullDeleter<LV2_Feature>};
}
private:
diff --git a/include/ingen/filesystem.hpp b/include/ingen/filesystem.hpp
index 5e64cc8c..5a90e7b7 100644
--- a/include/ingen/filesystem.hpp
+++ b/include/ingen/filesystem.hpp
@@ -75,7 +75,7 @@ inline FilePath current_path()
std::unique_ptr<char, Freer> cpath(realpath(".", nullptr));
- return FilePath(cpath.get());
+ return {cpath.get()};
}
} // namespace filesystem
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp
index 761c271b..ac52082f 100644
--- a/src/AtomReader.cpp
+++ b/src/AtomReader.cpp
@@ -83,7 +83,7 @@ boost::optional<URI>
AtomReader::atom_to_uri(const LV2_Atom* atom)
{
if (!atom) {
- return boost::optional<URI>();
+ return {};
}
if (atom->type == _uris.atom_URI) {
@@ -112,7 +112,7 @@ AtomReader::atom_to_uri(const LV2_Atom* atom)
_log.warn("Unknown URID %1%\n", str);
}
- return boost::optional<URI>();
+ return {};
}
boost::optional<raul::Path>
@@ -122,7 +122,7 @@ AtomReader::atom_to_path(const LV2_Atom* atom)
if (uri && uri_is_path(*uri)) {
return uri_to_path(*uri);
}
- return boost::optional<raul::Path>();
+ return {};
}
Resource::Graph
diff --git a/src/FilePath.cpp b/src/FilePath.cpp
index f8da196e..8cbd3a9e 100644
--- a/src/FilePath.cpp
+++ b/src/FilePath.cpp
@@ -105,7 +105,7 @@ FilePath::root_name()
}
#endif
- return FilePath();
+ return {};
}
FilePath
diff --git a/src/Forge.cpp b/src/Forge.cpp
index 6b8f7b14..abce74f2 100644
--- a/src/Forge.cpp
+++ b/src/Forge.cpp
@@ -35,7 +35,7 @@ Atom
Forge::make_urid(const ingen::URI& u)
{
const LV2_URID urid = _map.map_uri(u.string());
- return Atom(sizeof(int32_t), URID, &urid);
+ return {sizeof(int32_t), URID, &urid};
}
std::string
diff --git a/src/Log.cpp b/src/Log.cpp
index bc11fe3d..e05caa21 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -162,7 +162,7 @@ Log::Feature::feature(World& world, Node* block)
f->URI = LV2_LOG__log;
f->data = &handle->lv2_log;
- return std::shared_ptr<LV2_Feature>(f, &free_log_feature);
+ return {f, &free_log_feature};
}
} // namespace ingen
diff --git a/src/Parser.cpp b/src/Parser.cpp
index 6e0ee7a1..7b25031c 100644
--- a/src/Parser.cpp
+++ b/src/Parser.cpp
@@ -168,7 +168,7 @@ get_port(ingen::World& world,
|| i->second.type() != world.forge().Int
|| i->second.get<int32_t>() < 0) {
world.log().error("Port %1% has no valid index\n", subject);
- return boost::optional<PortRecord>();
+ return {};
}
*index = i->second.get<int32_t>();
}
@@ -189,7 +189,7 @@ get_port(ingen::World& world,
if (!raul::Symbol::is_valid(sym)) {
world.log().error("Port %1% has invalid symbol `%2%'\n", subject, sym);
- return boost::optional<PortRecord>();
+ return {};
}
const raul::Symbol port_sym(sym);
@@ -270,7 +270,7 @@ parse_block(ingen::World& world,
if (!prototype.is_valid()) {
world.log().error("Block %1% (%2%) missing mandatory lv2:prototype\n",
subject, path);
- return boost::optional<raul::Path>();
+ return {};
}
const auto* type_uri =
@@ -361,7 +361,7 @@ parse_graph(ingen::World& world,
world, model, port, ctx, graph_path, &index);
if (!port_record) {
world.log().error("Invalid port %1%\n", port);
- return boost::optional<raul::Path>();
+ return {};
}
// Store port information in ports map
@@ -412,7 +412,7 @@ parse_graph(ingen::World& world,
world, model, port, subctx, block_path, nullptr);
if (!port_record) {
world.log().error("Invalid port %1%\n", port);
- return boost::optional<raul::Path>();
+ return {};
}
// Create port and/or set all port properties
@@ -577,7 +577,7 @@ parse(ingen::World& world,
}
}
- return boost::optional<raul::Path>();
+ return {};
}
bool
diff --git a/src/URI.cpp b/src/URI.cpp
index 339ca07c..cc40a9a3 100644
--- a/src/URI.cpp
+++ b/src/URI.cpp
@@ -125,7 +125,7 @@ URI::make_relative(const URI& base) const
{
SerdURI uri;
SerdNode node = serd_node_new_relative_uri(&_uri, &base._uri, nullptr, &uri);
- return URI(node, uri);
+ return {node, uri};
}
} // namespace ingen
diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp
index 6082faed..4ea1536d 100644
--- a/src/gui/PropertiesWindow.cpp
+++ b/src/gui/PropertiesWindow.cpp
@@ -512,7 +512,7 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget)
}
}
- return Atom();
+ return {};
}
void
diff --git a/src/runtime_paths.cpp b/src/runtime_paths.cpp
index d90ab1c7..86315be8 100644
--- a/src/runtime_paths.cpp
+++ b/src/runtime_paths.cpp
@@ -138,28 +138,28 @@ FilePath
user_config_dir()
{
if (const char* xdg_config_home = getenv("XDG_CONFIG_HOME")) {
- return FilePath(xdg_config_home);
+ return {xdg_config_home};
}
if (const char* home = getenv("HOME")) {
return FilePath(home) / ".config";
}
- return FilePath();
+ return {};
}
FilePath
user_data_dir()
{
if (const char* xdg_data_home = getenv("XDG_DATA_HOME")) {
- return FilePath(xdg_data_home);
+ return {xdg_data_home};
}
if (const char* home = getenv("HOME")) {
return FilePath(home) / ".local/share";
}
- return FilePath();
+ return {};
}
std::vector<FilePath>
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index ed3566aa..9d63f78e 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -117,7 +117,7 @@ public:
/** Save current state as preset. */
virtual boost::optional<Resource>
save_preset(const URI& bundle,
- const Properties& props) { return boost::optional<Resource>(); }
+ const Properties& props) { return {}; }
/** Learn the next incoming MIDI event (for internals) */
virtual void learn() {}
diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp
index 348dbca6..8ed4eaae 100644
--- a/src/server/BufferFactory.cpp
+++ b/src/server/BufferFactory.cpp
@@ -150,7 +150,7 @@ BufferFactory::get_buffer(LV2_URID type,
try_head->_next = nullptr;
try_head->set_type(&BufferFactory::get_buffer, type, value_type);
try_head->clear();
- return BufferRef(try_head);
+ return {try_head};
}
BufferRef
@@ -159,12 +159,12 @@ BufferFactory::claim_buffer(LV2_URID type, LV2_URID value_type, uint32_t)
Buffer* try_head = try_get_buffer(type);
if (!try_head) {
_engine.world().log().rt_error("Failed to obtain buffer");
- return BufferRef();
+ return {};
}
try_head->_next = nullptr;
try_head->set_type(&BufferFactory::claim_buffer, type, value_type);
- return BufferRef(try_head);
+ return {try_head};
}
BufferRef
@@ -185,7 +185,7 @@ BufferFactory::create(LV2_URID type, LV2_URID value_type, uint32_t capacity)
capacity = std::max(capacity, default_size(_uris.atom_Sound));
}
- return BufferRef(new Buffer(*this, type, value_type, capacity));
+ return {new Buffer(*this, type, value_type, capacity)};
}
void
diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp
index 35a06368..4cdcecd7 100644
--- a/src/server/LV2Block.cpp
+++ b/src/server/LV2Block.cpp
@@ -758,7 +758,7 @@ LV2Block::save_preset(const URI& uri,
return {preset};
}
- return boost::optional<Resource>();
+ return {};
}
void
diff --git a/src/server/LV2Options.hpp b/src/server/LV2Options.hpp
index 50544e01..02824be6 100644
--- a/src/server/LV2Options.hpp
+++ b/src/server/LV2Options.hpp
@@ -66,7 +66,7 @@ public:
f->URI = LV2_OPTIONS__options;
f->data = malloc(sizeof(options));
memcpy(f->data, options, sizeof(options));
- return std::shared_ptr<LV2_Feature>(f, &free_feature);
+ return {f, &free_feature};
}
private:
diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp
index 0d377732..ed874634 100644
--- a/src/server/SocketListener.cpp
+++ b/src/server/SocketListener.cpp
@@ -51,7 +51,7 @@ get_link_target(const char* link_path)
// Stat the link to get the required size for the target path
struct stat link_stat{};
if (lstat(link_path, &link_stat)) {
- return std::string();
+ return {};
}
// Allocate buffer and read link target
@@ -63,7 +63,7 @@ get_link_target(const char* link_path)
}
free(target);
- return std::string();
+ return {};
}
static void ingen_listen(Engine* engine,
diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp
index 149d91e7..5b4da498 100644
--- a/src/server/Worker.cpp
+++ b/src/server/Worker.cpp
@@ -110,7 +110,7 @@ Worker::Schedule::feature(World&, Node* n)
f->URI = LV2_WORKER__schedule;
f->data = data;
- return std::shared_ptr<LV2_Feature>(f, &free_feature);
+ return {f, &free_feature};
}
Worker::Worker(Log& log, uint32_t buffer_size, bool synchronous)