summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-08-18 01:22:18 -0400
committerDavid Robillard <d@drobilla.net>2022-08-18 01:22:18 -0400
commit3af246bb3291d8568f6d110884fa55ee5fd20221 (patch)
tree434ac316050356e4db379ba8305b75285b17bbba /src
parent44381dbda9dbf8d20894789fe8e3ea941b70a1d0 (diff)
downloadingen-3af246bb3291d8568f6d110884fa55ee5fd20221.tar.gz
ingen-3af246bb3291d8568f6d110884fa55ee5fd20221.tar.bz2
ingen-3af246bb3291d8568f6d110884fa55ee5fd20221.zip
Avoid "else" after "return", "break", and "continue"
Diffstat (limited to 'src')
-rw-r--r--src/AtomReader.cpp42
-rw-r--r--src/ClashAvoider.cpp122
-rw-r--r--src/Configuration.cpp13
-rw-r--r--src/Log.cpp4
-rw-r--r--src/Parser.cpp14
-rw-r--r--src/Resource.cpp18
-rw-r--r--src/SocketReader.cpp8
-rw-r--r--src/Store.cpp7
-rw-r--r--src/client/BlockModel.cpp8
-rw-r--r--src/client/ClientStore.cpp24
-rw-r--r--src/client/GraphModel.cpp4
-rw-r--r--src/client/PluginModel.cpp28
-rw-r--r--src/gui/.clang-tidy1
-rw-r--r--src/gui/App.cpp4
-rw-r--r--src/gui/BreadCrumbs.cpp8
-rw-r--r--src/gui/ConnectWindow.cpp16
-rw-r--r--src/gui/GraphCanvas.cpp16
-rw-r--r--src/gui/GraphTreeWindow.cpp4
-rw-r--r--src/gui/LoadGraphWindow.cpp4
-rw-r--r--src/gui/LoadPluginWindow.cpp4
-rw-r--r--src/gui/NodeModule.cpp12
-rw-r--r--src/gui/Port.cpp8
-rw-r--r--src/gui/PropertiesWindow.cpp35
-rw-r--r--src/gui/Style.cpp21
-rw-r--r--src/gui/WidgetFactory.cpp4
-rw-r--r--src/gui/WindowFactory.cpp4
-rw-r--r--src/ingen/ingen.cpp8
-rw-r--r--src/runtime_paths.cpp10
-rw-r--r--src/server/.clang-tidy1
-rw-r--r--src/server/BlockImpl.cpp4
-rw-r--r--src/server/Buffer.cpp8
-rw-r--r--src/server/Buffer.hpp15
-rw-r--r--src/server/BufferFactory.cpp20
-rw-r--r--src/server/BufferFactory.hpp12
-rw-r--r--src/server/ControlBindings.cpp4
-rw-r--r--src/server/DuplexPort.cpp10
-rw-r--r--src/server/GraphImpl.cpp4
-rw-r--r--src/server/InternalPlugin.cpp20
-rw-r--r--src/server/JackDriver.cpp6
-rw-r--r--src/server/LV2Block.cpp4
-rw-r--r--src/server/LV2Plugin.cpp8
-rw-r--r--src/server/PortAudioDriver.cpp4
-rw-r--r--src/server/PortImpl.cpp12
-rw-r--r--src/server/PreProcessContext.hpp8
-rw-r--r--src/server/PreProcessor.cpp4
-rw-r--r--src/server/SocketListener.cpp8
-rw-r--r--src/server/UndoStack.cpp24
-rw-r--r--src/server/events/Copy.cpp18
-rw-r--r--src/server/events/CreateBlock.cpp15
-rw-r--r--src/server/events/CreateGraph.cpp6
-rw-r--r--src/server/events/CreatePort.cpp18
-rw-r--r--src/server/events/Delta.cpp9
-rw-r--r--src/server/events/Disconnect.cpp4
-rw-r--r--src/server/events/Get.cpp16
-rw-r--r--src/server/ingen_lv2.cpp4
55 files changed, 449 insertions, 268 deletions
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp
index 74476b83..e6d125e7 100644
--- a/src/AtomReader.cpp
+++ b/src/AtomReader.cpp
@@ -83,29 +83,34 @@ AtomReader::atom_to_uri(const LV2_Atom* atom)
{
if (!atom) {
return boost::optional<URI>();
- } else if (atom->type == _uris.atom_URI) {
+ }
+
+ if (atom->type == _uris.atom_URI) {
const char* str = static_cast<const char*>(LV2_ATOM_BODY_CONST(atom));
if (URI::is_valid(str)) {
return URI(str);
- } else {
- _log.warn("Invalid URI <%1%>\n", str);
}
+
+ _log.warn("Invalid URI <%1%>\n", str);
} else if (atom->type == _uris.atom_Path) {
const char* str = static_cast<const char*>(LV2_ATOM_BODY_CONST(atom));
if (!strncmp(str, "file://", 5)) {
return URI(str);
- } else {
- return URI(std::string("file://") + str);
}
- } else if (atom->type == _uris.atom_URID) {
+
+ return URI(std::string("file://") + str);
+ }
+
+ if (atom->type == _uris.atom_URID) {
const char* str =
_map.unmap_uri(reinterpret_cast<const LV2_Atom_URID*>(atom)->body);
if (str) {
return URI(str);
- } else {
- _log.warn("Unknown URID %1%\n", str);
}
+
+ _log.warn("Unknown URID %1%\n", str);
}
+
return boost::optional<URI>();
}
@@ -195,7 +200,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
if (subject_uri && !body) {
_iface(Del{seq, *subject_uri});
return true;
- } else if (body && body->body.otype == _uris.ingen_Arc) {
+ }
+
+ if (body && body->body.otype == _uris.ingen_Arc) {
const LV2_Atom* tail = nullptr;
const LV2_Atom* head = nullptr;
const LV2_Atom* incidentTo = nullptr;
@@ -228,7 +235,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
if (!body) {
_log.warn("Put message has no body\n");
return false;
- } else if (!subject_uri) {
+ }
+
+ if (!subject_uri) {
_log.warn("Put message has no subject\n");
return false;
}
@@ -275,7 +284,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
reinterpret_cast<const LV2_Atom*>(prop)->type != _uris.atom_URID) {
_log.warn("Set message missing property\n");
return false;
- } else if (!value) {
+ }
+
+ if (!value) {
_log.warn("Set message missing value\n");
return false;
}
@@ -304,7 +315,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
if (!remove) {
_log.warn("Patch message has no remove\n");
return false;
- } else if (!add) {
+ }
+
+ if (!add) {
_log.warn("Patch message has no add\n");
return false;
}
@@ -377,10 +390,13 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
if (!number || number->type != _uris.atom_Int) {
_log.warn("Response message has no sequence number\n");
return false;
- } else if (!body || body->type != _uris.atom_Int) {
+ }
+
+ if (!body || body->type != _uris.atom_Int) {
_log.warn("Response message body is not integer\n");
return false;
}
+
_iface(Response{reinterpret_cast<const LV2_Atom_Int*>(number)->body,
static_cast<ingen::Status>(
reinterpret_cast<const LV2_Atom_Int*>(body)->body),
diff --git a/src/ClashAvoider.cpp b/src/ClashAvoider.cpp
index 7c770cea..cd1c10bd 100644
--- a/src/ClashAvoider.cpp
+++ b/src/ClashAvoider.cpp
@@ -42,9 +42,9 @@ ClashAvoider::map_uri(const URI& in)
{
if (uri_is_path(in)) {
return path_to_uri(map_path(uri_to_path(in)));
- } else {
- return in;
}
+
+ return in;
}
raul::Path
@@ -71,66 +71,68 @@ ClashAvoider::map_path(const raul::Path& in)
auto m = _symbol_map.find(in);
if (m != _symbol_map.end()) {
return m->second;
- } else {
- // See if parent is mapped
- raul::Path parent = in.parent();
- do {
- auto p = _symbol_map.find(parent);
- if (p != _symbol_map.end()) {
- const raul::Path mapped = raul::Path(
- p->second.base() + in.substr(parent.base().length()));
- auto i = _symbol_map.emplace(in, mapped);
- return i.first->second;
- }
- parent = parent.parent();
- } while (!parent.is_root());
+ }
- if (!exists(in) && _symbol_map.find(in) == _symbol_map.end()) {
- // No clash, use symbol unmodified
- auto i = _symbol_map.emplace(in, in);
- assert(i.second);
+ // See if parent is mapped
+ raul::Path parent = in.parent();
+ do {
+ auto p = _symbol_map.find(parent);
+ if (p != _symbol_map.end()) {
+ const raul::Path mapped = raul::Path(
+ p->second.base() + in.substr(parent.base().length()));
+ auto i = _symbol_map.emplace(in, mapped);
return i.first->second;
+ }
+ parent = parent.parent();
+ } while (!parent.is_root());
+
+ if (!exists(in) && _symbol_map.find(in) == _symbol_map.end()) {
+ // No clash, use symbol unmodified
+ auto i = _symbol_map.emplace(in, in);
+ assert(i.second);
+ return i.first->second;
+ }
+ // Append _2 _3 etc until an unused symbol is found
+ while (true) {
+ auto o = _offsets.find(base_path);
+ if (o != _offsets.end()) {
+ offset = ++o->second;
} else {
- // Append _2 _3 etc until an unused symbol is found
- while (true) {
- auto o = _offsets.find(base_path);
- if (o != _offsets.end()) {
- offset = ++o->second;
- } else {
- std::string parent_str = in.parent().base();
- parent_str = parent_str.substr(0, parent_str.find_last_of('/'));
- if (parent_str.empty()) {
- parent_str = "/";
- }
- }
-
- if (offset == 0) {
- offset = 2;
- }
-
- std::stringstream ss;
- ss << base_path << "_" << offset;
- if (!exists(raul::Path(ss.str()))) {
- std::string name = base_path.symbol();
- if (name.empty()) {
- name = "_";
- }
- raul::Symbol sym(name);
- std::string str = ss.str();
- auto i = _symbol_map.emplace(in, raul::Path(str));
- offset = _store.child_name_offset(in.parent(), sym, false);
- _offsets.emplace(base_path, offset);
- return i.first->second;
- } else {
- if (o != _offsets.end()) {
- offset = ++o->second;
- } else {
- ++offset;
- }
- }
+ std::string parent_str = in.parent().base();
+ parent_str = parent_str.substr(0, parent_str.find_last_of('/'));
+ if (parent_str.empty()) {
+ parent_str = "/";
}
}
+
+ if (offset == 0) {
+ offset = 2;
+ }
+
+ std::stringstream ss;
+ ss << base_path << "_" << offset;
+ if (!exists(raul::Path(ss.str()))) {
+ std::string name = base_path.symbol();
+ if (name.empty()) {
+ name = "_";
+ }
+
+ raul::Symbol sym(name);
+ std::string str = ss.str();
+
+ auto i = _symbol_map.emplace(in, raul::Path(str));
+
+ offset = _store.child_name_offset(in.parent(), sym, false);
+ _offsets.emplace(base_path, offset);
+ return i.first->second;
+ }
+
+ if (o != _offsets.end()) {
+ offset = ++o->second;
+ } else {
+ ++offset;
+ }
}
}
@@ -175,11 +177,11 @@ ClashAvoider::adjust_name(const raul::Path& old_path,
const auto offset = new_suffix - old_suffix;
return (name.substr(0, *name_suffix_start) +
std::to_string(name_suffix + offset));
- } else {
- // Add 1 to previous label suffix
- return (name.substr(0, *name_suffix_start) +
- std::to_string(name_suffix + 1));
}
+
+ // Add 1 to previous label suffix
+ return (name.substr(0, *name_suffix_start) +
+ std::to_string(name_suffix + 1));
}
} // namespace ingen
diff --git a/src/Configuration.cpp b/src/Configuration.cpp
index 8fe12c79..794cf193 100644
--- a/src/Configuration.cpp
+++ b/src/Configuration.cpp
@@ -109,9 +109,12 @@ Configuration::variable_string(LV2_URID type) const
{
if (type == _forge.String) {
return "=STRING";
- } else if (type == _forge.Int) {
+ }
+
+ if (type == _forge.Int) {
return "=INT";
}
+
return "";
}
@@ -186,7 +189,9 @@ Configuration::parse(int argc, char** argv)
const auto o = _options.find(name);
if (o == _options.end()) {
throw OptionError(fmt("Unrecognized option `%1%'", name));
- } else if (o->second.type == _forge.Bool) { // --flag
+ }
+
+ if (o->second.type == _forge.Bool) { // --flag
o->second.value = _forge.make(true);
} else if (equals) { // --opt=val
set_value_from_string(o->second, equals + 1);
@@ -379,9 +384,9 @@ Configuration::option(const std::string& long_name) const
auto o = _options.find(long_name);
if (o == _options.end()) {
return nil;
- } else {
- return o->second.value;
}
+
+ return o->second.value;
}
bool
diff --git a/src/Log.cpp b/src/Log.cpp
index 23bbcf3f..b52f470c 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -87,7 +87,9 @@ Log::vtprintf(LV2_URID type, const char* fmt, va_list args)
int ret = 0;
if (type == _uris.log_Trace && !_trace) {
return 0;
- } else if (_sink) {
+ }
+
+ if (_sink) {
_sink(type, fmt, args);
}
diff --git a/src/Parser.cpp b/src/Parser.cpp
index f853d1b5..a1661625 100644
--- a/src/Parser.cpp
+++ b/src/Parser.cpp
@@ -450,7 +450,9 @@ parse_arc(ingen::World& world,
if (t.end()) {
world.log().error("Arc has no tail\n");
return false;
- } else if (h.end()) {
+ }
+
+ if (h.end()) {
world.log().error("Arc has no head\n");
return false;
}
@@ -472,7 +474,9 @@ parse_arc(ingen::World& world,
if (!(++t).end()) {
world.log().error("Arc has multiple tails\n");
return false;
- } else if (!(++h).end()) {
+ }
+
+ if (!(++h).end()) {
world.log().error("Arc has multiple heads\n");
return false;
}
@@ -660,10 +664,10 @@ Parser::parse_file(ingen::World& world,
URI(INGEN__file),
world.forge().alloc_uri(uri.string()));
return true;
- } else {
- world.log().warn("Document URI lost\n");
- return false;
}
+
+ world.log().warn("Document URI lost\n");
+ return false;
}
boost::optional<URI>
diff --git a/src/Resource.cpp b/src/Resource.cpp
index 48d541f8..2171c438 100644
--- a/src/Resource.cpp
+++ b/src/Resource.cpp
@@ -69,11 +69,11 @@ Resource::set_property(const URI& uri, const Atom& value, Resource::Graph ctx)
const Atom& v = _properties.emplace(uri, Property(value, ctx))->second;
on_property(uri, v);
return v;
- } else {
- // Announce ephemeral activity, but do not store
- on_property(uri, value);
- return value;
}
+
+ // Announce ephemeral activity, but do not store
+ on_property(uri, value);
+ return value;
}
const Atom&
@@ -176,14 +176,14 @@ Resource::type(const URIs& uris,
if (graph && block && !port) { // => graph
block = false;
return true;
- } else if (port && (graph || block)) { // nonsense
+ }
+
+ if (port && (graph || block)) { // nonsense
port = false;
return false;
- } else if (graph || block || port) { // recognized type
- return true;
- } else { // unknown
- return false;
}
+
+ return graph || block || port; // recognized type
}
void
diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp
index d4b400bb..c7b64166 100644
--- a/src/SocketReader.cpp
+++ b/src/SocketReader.cpp
@@ -167,7 +167,9 @@ SocketReader::run()
if (ret == -1 || (pfd.revents & (POLLERR|POLLHUP|POLLNVAL))) {
on_hangup();
break; // Hangup
- } else if (!ret) {
+ }
+
+ if (!ret) {
continue; // No data, shouldn't happen
}
@@ -178,7 +180,9 @@ SocketReader::run()
SerdStatus st = serd_reader_read_chunk(reader);
if (st == SERD_FAILURE || !_msg_node) {
continue; // Read nothing, e.g. just whitespace
- } else if (st) {
+ }
+
+ if (st) {
_world.log().error("Read error: %1%\n", serd_strerror(st));
continue;
}
diff --git a/src/Store.cpp b/src/Store.cpp
index 1dd5b146..363ffb41 100644
--- a/src/Store.cpp
+++ b/src/Store.cpp
@@ -134,14 +134,13 @@ Store::child_name_offset(const raul::Path& parent,
if (offset > 0) {
ss << "_" << offset;
}
+
if (find(parent.child(raul::Symbol(ss.str()))) == end() &&
(allow_zero || offset > 0)) {
break;
- } else if (offset == 0) {
- offset = 2;
- } else {
- ++offset;
}
+
+ offset = (offset == 0) ? 2 : (offset + 1);
}
return offset;
diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp
index ad216678..256c41f0 100644
--- a/src/client/BlockModel.cpp
+++ b/src/client/BlockModel.cpp
@@ -246,11 +246,13 @@ BlockModel::label() const
const Atom& name_property = get_property(_uris.lv2_name);
if (name_property.type() == _uris.forge.String) {
return name_property.ptr<char>();
- } else if (plugin_model()) {
+ }
+
+ if (plugin_model()) {
return plugin_model()->human_name();
- } else {
- return symbol().c_str();
}
+
+ return symbol().c_str();
}
std::string
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index 9728cc4f..80143265 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -168,12 +168,12 @@ ClientStore::_object(const raul::Path& path)
const auto i = find(path);
if (i == end()) {
return nullptr;
- } else {
- auto model = std::dynamic_pointer_cast<ObjectModel>(i->second);
- assert(model);
- assert(model->path().is_root() || model->parent());
- return model;
}
+
+ auto model = std::dynamic_pointer_cast<ObjectModel>(i->second);
+ assert(model);
+ assert(model->path().is_root() || model->parent());
+ return model;
}
std::shared_ptr<const ObjectModel>
@@ -187,9 +187,9 @@ ClientStore::_resource(const URI& uri)
{
if (uri_is_path(uri)) {
return _object(uri_to_path(uri));
- } else {
- return _plugin(uri);
}
+
+ return _plugin(uri);
}
std::shared_ptr<const Resource>
@@ -281,7 +281,9 @@ ClientStore::operator()(const Put& msg)
plug->add_preset(uri, l->second.ptr<char>());
}
return;
- } else if (_uris.ingen_Graph == type) {
+ }
+
+ if (_uris.ingen_Graph == type) {
is_graph = true;
} else if (_uris.ingen_Internal == type || _uris.lv2_Plugin == type) {
std::shared_ptr<PluginModel> p(new PluginModel(uris(), uri, type, properties));
@@ -452,10 +454,10 @@ ClientStore::attempt_connection(const raul::Path& tail_path,
std::shared_ptr<ArcModel> arc(new ArcModel(tail, head));
graph->add_arc(arc);
return true;
- } else {
- _log.warn("Failed to connect %1% => %2%\n", tail_path, head_path);
- return false;
}
+
+ _log.warn("Failed to connect %1% => %2%\n", tail_path, head_path);
+ return false;
}
void
diff --git a/src/client/GraphModel.cpp b/src/client/GraphModel.cpp
index d4104742..7829a241 100644
--- a/src/client/GraphModel.cpp
+++ b/src/client/GraphModel.cpp
@@ -108,9 +108,9 @@ GraphModel::get_arc(const Node* tail, const Node* head)
auto i = _arcs.find(std::make_pair(tail, head));
if (i != _arcs.end()) {
return std::dynamic_pointer_cast<ArcModel>(i->second);
- } else {
- return nullptr;
}
+
+ return nullptr;
}
/** Add a connection to this graph.
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index a6784928..6ba989b9 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -125,15 +125,21 @@ PluginModel::get_property(const URI& key) const
ret = set_property(
key, _uris.forge.make_urid(URI(lilv_node_as_uri(value))));
break;
- } else if (lilv_node_is_string(value)) {
+ }
+
+ if (lilv_node_is_string(value)) {
ret = set_property(
key, _uris.forge.alloc(lilv_node_as_string(value)));
break;
- } else if (lilv_node_is_float(value)) {
+ }
+
+ if (lilv_node_is_float(value)) {
ret = set_property(
key, _uris.forge.make(lilv_node_as_float(value)));
break;
- } else if (lilv_node_is_int(value)) {
+ }
+
+ if (lilv_node_is_int(value)) {
ret = set_property(
key, _uris.forge.make(lilv_node_as_int(value)));
break;
@@ -179,9 +185,9 @@ PluginModel::default_block_symbol() const
const Atom& name_atom = get_property(_uris.lv2_symbol);
if (name_atom.is_valid() && name_atom.type() == _uris.forge.String) {
return raul::Symbol::symbolify(name_atom.ptr<char>());
- } else {
- return raul::Symbol("_");
}
+
+ return raul::Symbol("_");
}
string
@@ -190,9 +196,9 @@ PluginModel::human_name() const
const Atom& name_atom = get_property(_uris.doap_name);
if (name_atom.type() == _uris.forge.String) {
return name_atom.ptr<char>();
- } else {
- return default_block_symbol().c_str();
}
+
+ return default_block_symbol().c_str();
}
string
@@ -255,9 +261,9 @@ heading(const std::string& text, bool html, unsigned level)
if (html) {
const std::string tag = std::string("h") + std::to_string(level);
return std::string("<") + tag + ">" + text + "</" + tag + ">\n";
- } else {
- return text + ":\n\n";
}
+
+ return text + ":\n\n";
}
static std::string
@@ -265,9 +271,9 @@ link(const std::string& addr, bool html)
{
if (html) {
return std::string("<a href=\"") + addr + "\">" + addr + "</a>";
- } else {
- return addr;
}
+
+ return addr;
}
std::string
diff --git a/src/gui/.clang-tidy b/src/gui/.clang-tidy
index 065c97b1..7f978910 100644
--- a/src/gui/.clang-tidy
+++ b/src/gui/.clang-tidy
@@ -1,7 +1,6 @@
Checks: >
*,
-*-avoid-c-arrays,
- -*-else-after-return,
-*-magic-numbers,
-*-named-parameter,
-*-narrowing-conversions,
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index 20d8898f..ff9636b9 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -317,7 +317,9 @@ App::property_change(const URI& subject,
{
if (subject != URI("ingen:/engine")) {
return;
- } else if (key == uris().param_sampleRate && value.type() == forge().Int) {
+ }
+
+ if (key == uris().param_sampleRate && value.type() == forge().Int) {
_sample_rate = value.get<int32_t>();
} else if (key == uris().bufsz_maxBlockLength && value.type() == forge().Int) {
_block_length = value.get<int32_t>();
diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp
index 0cd2c5ad..041c3f51 100644
--- a/src/gui/BreadCrumbs.cpp
+++ b/src/gui/BreadCrumbs.cpp
@@ -104,9 +104,9 @@ BreadCrumbs::build(const raul::Path& path,
but->show();
if (suffix.find('/') == string::npos) {
break;
- } else {
- suffix = suffix.substr(suffix.find('/') + 1);
}
+
+ suffix = suffix.substr(suffix.find('/') + 1);
}
for (const auto& b : _breadcrumbs) {
@@ -148,9 +148,9 @@ BreadCrumbs::build(const raul::Path& path,
but->show();
if (suffix.find('/') == string::npos) {
break;
- } else {
- suffix = suffix.substr(suffix.find('/')+1);
}
+
+ suffix = suffix.substr(suffix.find('/')+1);
}
}
diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp
index a5e6fbd4..20e7d33e 100644
--- a/src/gui/ConnectWindow.cpp
+++ b/src/gui/ConnectWindow.cpp
@@ -215,10 +215,10 @@ ConnectWindow::connect(bool existing)
if (_app->client()) {
error("Already connected");
return;
- } else if (_attached) {
- _attached = false;
}
+ _attached = false;
+
set_connecting_widget_states();
_connect_stage = 0;
@@ -265,10 +265,14 @@ ConnectWindow::connect(bool existing)
if (!world.load_module("server")) {
error("Failed to load server module");
return;
- } else if (!world.load_module("jack")) {
+ }
+
+ if (!world.load_module("jack")) {
error("Failed to load jack module");
return;
- } else if (!world.engine()->activate()) {
+ }
+
+ if (!world.engine()->activate()) {
error("Failed to activate engine");
return;
}
@@ -556,9 +560,9 @@ ConnectWindow::gtk_callback()
_progress_label->set_text(std::string("Disconnected"));
}
return false;
- } else {
- return true;
}
+
+ return true;
}
void
diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp
index 636a3d9f..5cd209de 100644
--- a/src/gui/GraphCanvas.cpp
+++ b/src/gui/GraphCanvas.cpp
@@ -436,14 +436,14 @@ GraphCanvas::get_port_view(const std::shared_ptr<PortModel>& port)
return ppm
? *ppm->begin()
: dynamic_cast<Ganv::Port*>(module);
- } else {
- module = dynamic_cast<NodeModule*>(_views[port->parent()]);
- if (module) {
- for (auto* p : *module) {
- auto* pv = dynamic_cast<gui::Port*>(p);
- if (pv && pv->model() == port) {
- return pv;
- }
+ }
+
+ module = dynamic_cast<NodeModule*>(_views[port->parent()]);
+ if (module) {
+ for (auto* p : *module) {
+ auto* pv = dynamic_cast<gui::Port*>(p);
+ if (pv && pv->model() == port) {
+ return pv;
}
}
}
diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp
index 7a787cb3..41ee92de 100644
--- a/src/gui/GraphTreeWindow.cpp
+++ b/src/gui/GraphTreeWindow.cpp
@@ -161,7 +161,9 @@ GraphTreeWindow::find_graph(Gtk::TreeModel::Children root,
std::shared_ptr<GraphModel> pm = (*c)[_graph_tree_columns.graph_model_col];
if (graph == pm) {
return c;
- } else if (!(*c)->children().empty()) {
+ }
+
+ if (!(*c)->children().empty()) {
auto ret = find_graph(c->children(), graph);
if (ret != c->children().end()) {
return ret;
diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp
index 7a80a2bf..b44a1fe7 100644
--- a/src/gui/LoadGraphWindow.cpp
+++ b/src/gui/LoadGraphWindow.cpp
@@ -251,9 +251,9 @@ LoadGraphWindow::avoid_symbol_clash(const raul::Symbol& symbol)
std::stringstream ss;
ss << symbol << "_" << offset;
return raul::Symbol(ss.str());
- } else {
- return symbol;
}
+
+ return symbol;
}
void
diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp
index e147fdf2..c858efa1 100644
--- a/src/gui/LoadPluginWindow.cpp
+++ b/src/gui/LoadPluginWindow.cpp
@@ -515,9 +515,9 @@ LoadPluginWindow::on_key_press_event(GdkEventKey* event)
if (event->keyval == GDK_w && event->state & GDK_CONTROL_MASK) {
hide();
return true;
- } else {
- return Gtk::Window::on_key_press_event(event);
}
+
+ return Gtk::Window::on_key_press_event(event);
}
void
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index c80947cb..6905318a 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -408,9 +408,9 @@ NodeModule::popup_gui()
_gui_window->present();
return true;
- } else {
- app().log().warn("No LV2 GUI for %1%\n", _block->path());
}
+
+ app().log().warn("No LV2 GUI for %1%\n", _block->path());
}
return false;
@@ -449,9 +449,13 @@ NodeModule::on_event(GdkEvent* ev)
{
if (ev->type == GDK_BUTTON_PRESS && ev->button.button == 3) {
return show_menu(&ev->button);
- } else if (ev->type == GDK_2BUTTON_PRESS) {
+ }
+
+ if (ev->type == GDK_2BUTTON_PRESS) {
return on_double_click(&ev->button);
- } else if (ev->type == GDK_ENTER_NOTIFY) {
+ }
+
+ if (ev->type == GDK_ENTER_NOTIFY) {
GraphBox* const box = app().window_factory()->graph_box(
std::dynamic_pointer_cast<const GraphModel>(_block->parent()));
if (box) {
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index 87cb3ef1..52f10edf 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -357,7 +357,9 @@ Port::on_event(GdkEvent* ev)
Gtk::Menu* menu = build_enum_menu();
menu->popup(ev->button.button, ev->button.time);
return true;
- } else if (model()->is_uri()) {
+ }
+
+ if (model()->is_uri()) {
Gtk::Menu* menu = build_uri_menu();
if (menu) {
menu->popup(ev->button.button, ev->button.time);
@@ -385,9 +387,9 @@ peak_color(float peak)
if (peak < 1.0f) {
return rgba_interpolate(min, max, peak);
- } else {
- return rgba_interpolate(peak_min, peak_max, fminf(peak, 2.0f) - 1.0f);
}
+
+ return rgba_interpolate(peak_min, peak_max, fminf(peak, 2.0f) - 1.0f);
}
void
diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp
index 3390c53e..15f1818e 100644
--- a/src/gui/PropertiesWindow.cpp
+++ b/src/gui/PropertiesWindow.cpp
@@ -184,16 +184,24 @@ PropertiesWindow::datatype_supported(const rdfs::URISet& types,
if (types.find(_app->uris().atom_Int) != types.end()) {
*widget_type = _app->uris().atom_Int;
return true;
- } else if (types.find(_app->uris().atom_Float) != types.end()) {
+ }
+
+ if (types.find(_app->uris().atom_Float) != types.end()) {
*widget_type = _app->uris().atom_Float;
return true;
- } else if (types.find(_app->uris().atom_Bool) != types.end()) {
+ }
+
+ if (types.find(_app->uris().atom_Bool) != types.end()) {
*widget_type = _app->uris().atom_Bool;
return true;
- } else if (types.find(_app->uris().atom_String) != types.end()) {
+ }
+
+ if (types.find(_app->uris().atom_String) != types.end()) {
*widget_type = _app->uris().atom_String;
return true;
- } else if (types.find(_app->uris().atom_URID) != types.end()) {
+ }
+
+ if (types.find(_app->uris().atom_URID) != types.end()) {
*widget_type = _app->uris().atom_URID;
return true;
}
@@ -332,7 +340,9 @@ PropertiesWindow::create_value_widget(const URI& key,
widget->signal_value_changed().connect(
sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key));
return widget;
- } else if (type == _app->uris().atom_Float) {
+ }
+
+ if (type == _app->uris().atom_Float) {
Gtk::SpinButton* widget = manage(new Gtk::SpinButton(0.0, 4));
widget->property_numeric() = true;
widget->set_snap_to_ticks(false);
@@ -344,7 +354,9 @@ PropertiesWindow::create_value_widget(const URI& key,
widget->signal_value_changed().connect(
sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key));
return widget;
- } else if (type == _app->uris().atom_Bool) {
+ }
+
+ if (type == _app->uris().atom_Bool) {
Gtk::CheckButton* widget = manage(new Gtk::CheckButton());
if (value.is_valid()) {
widget->set_active(value.get<int32_t>());
@@ -352,7 +364,9 @@ PropertiesWindow::create_value_widget(const URI& key,
widget->signal_toggled().connect(
sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key));
return widget;
- } else if (type == _app->uris().atom_String) {
+ }
+
+ if (type == _app->uris().atom_String) {
Gtk::Entry* widget = manage(new Gtk::Entry());
if (value.is_valid()) {
widget->set_text(value.ptr<char>());
@@ -360,7 +374,9 @@ PropertiesWindow::create_value_widget(const URI& key,
widget->signal_changed().connect(
sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key));
return widget;
- } else if (type == _app->uris().atom_URID) {
+ }
+
+ if (type == _app->uris().atom_URID) {
const char* str = (value.is_valid()
? world.uri_map().unmap_uri(value.get<int32_t>())
: "");
@@ -486,9 +502,8 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget)
auto* uri_entry = dynamic_cast<URIEntry*>(value_widget);
if (uri_entry && URI::is_valid(uri_entry->get_text())) {
return _app->forge().make_urid(URI(uri_entry->get_text()));
- } else {
- _app->log().error("Invalid URI <%1%>\n", uri_entry->get_text());
}
+ _app->log().error("Invalid URI <%1%>\n", uri_entry->get_text());
} else if (type == forge.String) {
auto* entry = dynamic_cast<Gtk::Entry*>(value_widget);
if (entry) {
diff --git a/src/gui/Style.cpp b/src/gui/Style.cpp
index 7b9e4dc7..bce98648 100644
--- a/src/gui/Style.cpp
+++ b/src/gui/Style.cpp
@@ -69,17 +69,28 @@ uint32_t
Style::get_port_color(const client::PortModel* p)
{
const URIs& uris = _app.uris();
+
if (p->is_a(uris.lv2_AudioPort)) {
return _audio_port_color;
- } else if (p->is_a(uris.lv2_ControlPort)) {
+ }
+
+ if (p->is_a(uris.lv2_ControlPort)) {
return _control_port_color;
- } else if (p->is_a(uris.lv2_CVPort)) {
+ }
+
+ if (p->is_a(uris.lv2_CVPort)) {
return _cv_port_color;
- } else if (p->supports(uris.atom_String)) {
+ }
+
+ if (p->supports(uris.atom_String)) {
return _string_port_color;
- } else if (_app.can_control(p)) {
+ }
+
+ if (_app.can_control(p)) {
return _control_port_color;
- } else if (p->is_a(uris.atom_AtomPort)) {
+ }
+
+ if (p->is_a(uris.atom_AtomPort)) {
return _event_port_color;
}
diff --git a/src/gui/WidgetFactory.cpp b/src/gui/WidgetFactory.cpp
index 2bd7b5fd..597e0924 100644
--- a/src/gui/WidgetFactory.cpp
+++ b/src/gui/WidgetFactory.cpp
@@ -72,9 +72,9 @@ WidgetFactory::create(const std::string& toplevel_widget)
if (toplevel_widget.empty()) {
return Gtk::Builder::create_from_file(ui_filename);
- } else {
- return Gtk::Builder::create_from_file(ui_filename, toplevel_widget.c_str());
}
+
+ return Gtk::Builder::create_from_file(ui_filename, toplevel_widget.c_str());
}
} // namespace gui
diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp
index 973a236b..8928b664 100644
--- a/src/gui/WindowFactory.cpp
+++ b/src/gui/WindowFactory.cpp
@@ -109,9 +109,9 @@ WindowFactory::graph_box(const std::shared_ptr<const GraphModel>& graph)
GraphWindow* window = graph_window(graph);
if (window) {
return window->box();
- } else {
- return _main_box;
}
+
+ return _main_box;
}
GraphWindow*
diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp
index 68ac2d7b..b19e6423 100644
--- a/src/ingen/ingen.cpp
+++ b/src/ingen/ingen.cpp
@@ -105,10 +105,14 @@ run(int argc, char** argv)
if (argc <= 1) {
world->conf().print_usage("ingen", std::cout);
return EXIT_FAILURE;
- } else if (world->conf().option("help").get<int32_t>()) {
+ }
+
+ if (world->conf().option("help").get<int32_t>()) {
world->conf().print_usage("ingen", std::cout);
return EXIT_SUCCESS;
- } else if (world->conf().option("version").get<int32_t>()) {
+ }
+
+ if (world->conf().option("version").get<int32_t>()) {
return print_version();
}
} catch (std::exception& e) {
diff --git a/src/runtime_paths.cpp b/src/runtime_paths.cpp
index b5723e94..d90ab1c7 100644
--- a/src/runtime_paths.cpp
+++ b/src/runtime_paths.cpp
@@ -139,9 +139,12 @@ user_config_dir()
{
if (const char* xdg_config_home = getenv("XDG_CONFIG_HOME")) {
return FilePath(xdg_config_home);
- } else if (const char* home = getenv("HOME")) {
+ }
+
+ if (const char* home = getenv("HOME")) {
return FilePath(home) / ".config";
}
+
return FilePath();
}
@@ -150,9 +153,12 @@ user_data_dir()
{
if (const char* xdg_data_home = getenv("XDG_DATA_HOME")) {
return FilePath(xdg_data_home);
- } else if (const char* home = getenv("HOME")) {
+ }
+
+ if (const char* home = getenv("HOME")) {
return FilePath(home) / ".local/share";
}
+
return FilePath();
}
diff --git a/src/server/.clang-tidy b/src/server/.clang-tidy
index d0448c00..fd06dfb6 100644
--- a/src/server/.clang-tidy
+++ b/src/server/.clang-tidy
@@ -1,7 +1,6 @@
Checks: >
*,
-*-avoid-c-arrays,
- -*-else-after-return,
-*-magic-numbers,
-*-named-parameter,
-*-narrowing-conversions,
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index a89df669..ee6b5786 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -207,7 +207,9 @@ BlockImpl::bypass(RunContext& ctx)
PortImpl* out = nth_port_by_type(i, false, t);
if (!out) {
break; // Finished writing all outputs
- } else if (in) {
+ }
+
+ if (in) {
// Copy corresponding input to output
for (uint32_t v = 0; v < _polyphony; ++v) {
out->buffer(v)->copy(ctx, in->buffer(v).get());
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index 18483d2d..199d858b 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -147,7 +147,9 @@ Buffer::copy(const RunContext& ctx, const Buffer* src)
{
if (!_buf) {
return;
- } else if (_type == src->type()) {
+ }
+
+ if (_type == src->type()) {
const uint32_t src_size = src->size();
if (src_size <= _capacity) {
memcpy(_buf, src->_buf, src_size);
@@ -416,7 +418,9 @@ Buffer::update_value_buffer(SampleCount offset)
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
if (ev->time.frames > offset) {
break;
- } else if (ev->body.type == _value_type) {
+ }
+
+ if (ev->body.type == _value_type) {
latest = ev;
}
}
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index b1d8fb4d..d10aeb5c 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -95,9 +95,12 @@ public:
if (is_control()) {
return static_cast<const Sample*>(
LV2_ATOM_BODY_CONST(get<LV2_Atom_Float>()));
- } else if (is_audio()) {
+ }
+
+ if (is_audio()) {
return static_cast<const Sample*>(_buf);
}
+
return nullptr;
}
@@ -105,9 +108,12 @@ public:
inline Sample* samples() {
if (is_control()) {
return static_cast<Sample*>(LV2_ATOM_BODY(get<LV2_Atom_Float>()));
- } else if (is_audio()) {
+ }
+
+ if (is_audio()) {
return static_cast<Sample*>(_buf);
}
+
return nullptr;
}
@@ -115,9 +121,12 @@ public:
inline Sample value_at(SampleCount offset) const {
if (is_audio() || is_control()) {
return samples()[offset];
- } else if (_value_buffer) {
+ }
+
+ if (_value_buffer) {
return reinterpret_cast<const LV2_Atom_Float*>(value())->body;
}
+
return 0.0f;
}
diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp
index 97a9b933..7c1e0b17 100644
--- a/src/server/BufferFactory.cpp
+++ b/src/server/BufferFactory.cpp
@@ -100,19 +100,25 @@ BufferFactory::default_size(LV2_URID type) const
{
if (type == _uris.atom_Float) {
return sizeof(LV2_Atom_Float);
- } else if (type == _uris.atom_Sound) {
+ }
+
+ if (type == _uris.atom_Sound) {
return audio_buffer_size(_engine.block_length());
- } else if (type == _uris.atom_URID) {
+ }
+
+ if (type == _uris.atom_URID) {
return sizeof(LV2_Atom_URID);
- } else if (type == _uris.atom_Sequence) {
+ }
+
+ if (type == _uris.atom_Sequence) {
if (_seq_size == 0) {
return _engine.sequence_size();
- } else {
- return _seq_size;
}
- } else {
- return 0;
+
+ return _seq_size;
}
+
+ return 0;
}
Buffer*
diff --git a/src/server/BufferFactory.hpp b/src/server/BufferFactory.hpp
index 5f649e4a..58c5bba2 100644
--- a/src/server/BufferFactory.hpp
+++ b/src/server/BufferFactory.hpp
@@ -85,13 +85,17 @@ private:
inline std::atomic<Buffer*>& free_list(LV2_URID type) {
if (type == _uris.atom_Float) {
return _free_control;
- } else if (type == _uris.atom_Sound) {
+ }
+
+ if (type == _uris.atom_Sound) {
return _free_audio;
- } else if (type == _uris.atom_Sequence) {
+ }
+
+ if (type == _uris.atom_Sequence) {
return _free_sequence;
- } else {
- return _free_object;
}
+
+ return _free_object;
}
static void free_list(Buffer* head);
diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp
index 60684440..f68c28d8 100644
--- a/src/server/ControlBindings.cpp
+++ b/src/server/ControlBindings.cpp
@@ -155,9 +155,9 @@ ControlBindings::set_port_binding(RunContext&,
binding->port = port;
_bindings->insert(*binding);
return true;
- } else {
- return false;
}
+
+ return false;
}
void
diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp
index ce516b46..0c4c83e6 100644
--- a/src/server/DuplexPort.cpp
+++ b/src/server/DuplexPort.cpp
@@ -154,9 +154,12 @@ DuplexPort::get_buffers(BufferFactory& bufs,
{
if (!_is_driver_port && is_output()) {
return InputPort::get_buffers(bufs, get, voices, poly, num_in_arcs);
- } else if (!_is_driver_port && is_input()) {
+ }
+
+ if (!_is_driver_port && is_input()) {
return PortImpl::get_buffers(bufs, get, voices, poly, num_in_arcs);
}
+
return false;
}
@@ -165,9 +168,12 @@ DuplexPort::setup_buffers(RunContext& ctx, BufferFactory& bufs, uint32_t poly)
{
if (!_is_driver_port && is_output()) {
return InputPort::setup_buffers(ctx, bufs, poly);
- } else if (!_is_driver_port && is_input()) {
+ }
+
+ if (!_is_driver_port && is_input()) {
return PortImpl::setup_buffers(ctx, bufs, poly);
}
+
return false;
}
diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp
index 7f566041..86a70495 100644
--- a/src/server/GraphImpl.cpp
+++ b/src/server/GraphImpl.cpp
@@ -297,9 +297,9 @@ GraphImpl::remove_arc(const PortImpl* tail, const PortImpl* dst_port)
auto arc = std::dynamic_pointer_cast<ArcImpl>(i->second);
_arcs.erase(i);
return arc;
- } else {
- return nullptr;
}
+
+ return nullptr;
}
bool
diff --git a/src/server/InternalPlugin.cpp b/src/server/InternalPlugin.cpp
index 0355ff1e..6c188c5e 100644
--- a/src/server/InternalPlugin.cpp
+++ b/src/server/InternalPlugin.cpp
@@ -51,21 +51,29 @@ InternalPlugin::instantiate(BufferFactory& bufs,
if (uri() == NS_INTERNALS "BlockDelay") {
return new internals::BlockDelayNode(
this, bufs, symbol, polyphonic, parent, srate);
- } else if (uri() == NS_INTERNALS "Controller") {
+ }
+
+ if (uri() == NS_INTERNALS "Controller") {
return new internals::ControllerNode(
this, bufs, symbol, polyphonic, parent, srate);
- } else if (uri() == NS_INTERNALS "Note") {
+ }
+
+ if (uri() == NS_INTERNALS "Note") {
return new internals::NoteNode(
this, bufs, symbol, polyphonic, parent, srate);
- } else if (uri() == NS_INTERNALS "Time") {
+ }
+
+ if (uri() == NS_INTERNALS "Time") {
return new internals::TimeNode(
this, bufs, symbol, polyphonic, parent, srate);
- } else if (uri() == NS_INTERNALS "Trigger") {
+ }
+
+ if (uri() == NS_INTERNALS "Trigger") {
return new internals::TriggerNode(
this, bufs, symbol, polyphonic, parent, srate);
- } else {
- return nullptr;
}
+
+ return nullptr;
}
} // namespace server
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index 472379f9..2a9fb321 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -153,10 +153,10 @@ JackDriver::activate()
if (jack_activate(_client)) {
_engine.log().error("Could not activate Jack client, aborting\n");
return false;
- } else {
- _engine.log().info("Activated Jack client `%1%'\n",
- world.conf().option("jack-name").ptr<char>());
}
+
+ _engine.log().info("Activated Jack client `%1%'\n",
+ world.conf().option("jack-name").ptr<char>());
return true;
}
diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp
index a0e67eb9..73eb85c9 100644
--- a/src/server/LV2Block.cpp
+++ b/src/server/LV2Block.cpp
@@ -496,7 +496,9 @@ LV2Block::save_state(const FilePath& dir) const
if (!state) {
return false;
- } else if (lilv_state_get_num_properties(state.get()) == 0) {
+ }
+
+ if (lilv_state_get_num_properties(state.get()) == 0) {
return false;
}
diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp
index 7a43ba67..121792c7 100644
--- a/src/server/LV2Plugin.cpp
+++ b/src/server/LV2Plugin.cpp
@@ -79,9 +79,9 @@ LV2Plugin::symbol() const
if ( (symbol[0] >= 'a' && symbol[0] <= 'z')
|| (symbol[0] >= 'A' && symbol[0] <= 'Z') ) {
return raul::Symbol::symbolify(symbol);
- } else {
- working = working.substr(0, last_slash);
}
+
+ working = working.substr(0, last_slash);
}
return raul::Symbol("lv2_symbol");
@@ -101,9 +101,9 @@ LV2Plugin::instantiate(BufferFactory& bufs,
if (!b->instantiate(bufs, state)) {
delete b;
return nullptr;
- } else {
- return b;
}
+
+ return b;
}
void
diff --git a/src/server/PortAudioDriver.cpp b/src/server/PortAudioDriver.cpp
index 68acf552..c6bfcc65 100644
--- a/src/server/PortAudioDriver.cpp
+++ b/src/server/PortAudioDriver.cpp
@@ -70,7 +70,9 @@ PortAudioDriver::attach()
_outputParameters.device = Pa_GetDefaultOutputDevice();
if (_inputParameters.device == paNoDevice) {
return pa_error("No default input device", paDeviceUnavailable);
- } else if (_outputParameters.device == paNoDevice) {
+ }
+
+ if (_outputParameters.device == paNoDevice) {
return pa_error("No default output device", paDeviceUnavailable);
}
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index 913c6176..23eb16ee 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -330,9 +330,13 @@ PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly)
if (_is_driver_port || _parent->is_main() ||
(_type == PortType::ATOM && !_value.is_valid())) {
return false;
- } else if (_poly == poly) {
+ }
+
+ if (_poly == poly) {
return true;
- } else if (_prepared_voices && _prepared_voices->size() != poly) {
+ }
+
+ if (_prepared_voices && _prepared_voices->size() != poly) {
_prepared_voices.reset();
}
@@ -353,7 +357,9 @@ PortImpl::apply_poly(RunContext& ctx, uint32_t poly)
if (_parent->is_main() ||
(_type == PortType::ATOM && !_value.is_valid())) {
return false;
- } else if (!_prepared_voices) {
+ }
+
+ if (!_prepared_voices) {
return true;
}
diff --git a/src/server/PreProcessContext.hpp b/src/server/PreProcessContext.hpp
index fa7d07c5..72dc64c3 100644
--- a/src/server/PreProcessContext.hpp
+++ b/src/server/PreProcessContext.hpp
@@ -50,12 +50,14 @@ public:
bool must_compile(GraphImpl& graph) {
if (!graph.enabled()) {
return false;
- } else if (_in_bundle) {
+ }
+
+ if (_in_bundle) {
_dirty_graphs.insert(&graph);
return false;
- } else {
- return true;
}
+
+ return true;
}
/** Compile graph and return the result if necessary.
diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp
index 6922d232..beba06e2 100644
--- a/src/server/PreProcessor.cpp
+++ b/src/server/PreProcessor.cpp
@@ -110,7 +110,9 @@ PreProcessor::process(RunContext& ctx, PostProcessor& dest, size_t limit)
if (_block_state == BlockState::BLOCKED) {
break; // Waiting for PRE_UNBLOCKED
- } else if (ev->time() < ctx.start()) {
+ }
+
+ if (ev->time() < ctx.start()) {
ev->set_time(ctx.start()); // Too late, nudge to context start
} else if (_block_state != BlockState::PROCESSING &&
ev->time() >= ctx.end()) {
diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp
index 445374c4..640d575f 100644
--- a/src/server/SocketListener.cpp
+++ b/src/server/SocketListener.cpp
@@ -165,10 +165,14 @@ ingen_listen(Engine* engine, raul::Socket* unix_sock, raul::Socket* net_sock)
if (ret == -1) {
world.log().error("Poll error: %1%\n", strerror(errno));
break;
- } else if (ret == 0) {
+ }
+
+ if (ret == 0) {
world.log().warn("Poll returned with no data\n");
continue;
- } else if ((pfds[0].revents & POLLHUP) || pfds[1].revents & POLLHUP) {
+ }
+
+ if ((pfds[0].revents & POLLHUP) || pfds[1].revents & POLLHUP) {
break;
}
diff --git a/src/server/UndoStack.cpp b/src/server/UndoStack.cpp
index 3dd4b3b0..858cb11b 100644
--- a/src/server/UndoStack.cpp
+++ b/src/server/UndoStack.cpp
@@ -87,18 +87,18 @@ UndoStack::ignore_later_event(const LV2_Atom* first,
int
UndoStack::finish_entry()
{
- if (--_depth > 0) {
- return _depth;
- } else if (_stack.back().events.empty()) {
- // Disregard empty entry
- _stack.pop_back();
- } else if (_stack.size() > 1 && _stack.back().events.size() == 1) {
- // This entry and the previous one have one event, attempt to merge
- auto i = _stack.rbegin();
- ++i;
- if (i->events.size() == 1) {
- if (ignore_later_event(i->events[0], _stack.back().events[0])) {
- _stack.pop_back();
+ if (--_depth == 0) {
+ if (_stack.back().events.empty()) {
+ // Disregard empty entry
+ _stack.pop_back();
+ } else if (_stack.size() > 1 && _stack.back().events.size() == 1) {
+ // This entry and the previous one have one event, attempt to merge
+ auto i = _stack.rbegin();
+ ++i;
+ if (i->events.size() == 1) {
+ if (ignore_later_event(i->events[0], _stack.back().events[0])) {
+ _stack.pop_back();
+ }
}
}
}
diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp
index 7f92842e..beb5224c 100644
--- a/src/server/events/Copy.cpp
+++ b/src/server/events/Copy.cpp
@@ -79,19 +79,23 @@ Copy::pre_process(PreProcessContext& ctx)
if (uri_is_path(_msg.new_uri)) {
// Copy to path within the engine
return engine_to_engine(ctx);
- } else if (_msg.new_uri.scheme() == "file") {
+ }
+
+ if (_msg.new_uri.scheme() == "file") {
// Copy to filesystem path (i.e. save)
return engine_to_filesystem(ctx);
- } else {
- return Event::pre_process_done(Status::BAD_REQUEST);
}
- } else if (_msg.old_uri.scheme() == "file") {
+
+ return Event::pre_process_done(Status::BAD_REQUEST);
+ }
+
+ if (_msg.old_uri.scheme() == "file") {
if (uri_is_path(_msg.new_uri)) {
return filesystem_to_engine(ctx);
- } else {
- // Ingen is not your file manager
- return Event::pre_process_done(Status::BAD_REQUEST);
}
+
+ // Ingen is not your file manager
+ return Event::pre_process_done(Status::BAD_REQUEST);
}
return Event::pre_process_done(Status::BAD_URI);
diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp
index 6d0dbe3e..23a0d35e 100644
--- a/src/server/events/CreateBlock.cpp
+++ b/src/server/events/CreateBlock.cpp
@@ -77,9 +77,13 @@ CreateBlock::pre_process(PreProcessContext& ctx)
// Check sanity of target path
if (_path.is_root()) {
return Event::pre_process_done(Status::BAD_URI, _path);
- } else if (store->get(_path)) {
+ }
+
+ if (store->get(_path)) {
return Event::pre_process_done(Status::EXISTS, _path);
- } else if (!(_graph = dynamic_cast<GraphImpl*>(store->get(_path.parent())))) {
+ }
+
+ if (!(_graph = dynamic_cast<GraphImpl*>(store->get(_path.parent())))) {
return Event::pre_process_done(Status::PARENT_NOT_FOUND, _path.parent());
}
@@ -115,8 +119,11 @@ CreateBlock::pre_process(PreProcessContext& ctx)
store->get(uri_to_path(prototype)));
if (!ancestor) {
return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND, prototype);
- } else if (!(_block = ancestor->duplicate(
- _engine, raul::Symbol(_path.symbol()), _graph))) {
+ }
+
+ if (!(_block = ancestor->duplicate(_engine,
+ raul::Symbol(_path.symbol()),
+ _graph))) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index 367bedfe..dc7c0d7d 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -167,8 +167,10 @@ CreateGraph::pre_process(PreProcessContext& ctx)
if (!ancestor) {
return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND,
prototype);
- } else if (!(_graph = dynamic_cast<GraphImpl*>(
- ancestor->duplicate(_engine, symbol, _parent)))) {
+ }
+
+ if (!(_graph = dynamic_cast<GraphImpl*>(
+ ancestor->duplicate(_engine, symbol, _parent)))) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
} else {
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 5ea9db33..6eee6ed7 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -94,9 +94,13 @@ CreatePort::pre_process(PreProcessContext&)
{
if (_port_type == PortType::UNKNOWN || !_flow) {
return Event::pre_process_done(Status::UNKNOWN_TYPE, _path);
- } else if (_path.is_root()) {
+ }
+
+ if (_path.is_root()) {
return Event::pre_process_done(Status::BAD_URI, _path);
- } else if (_engine.store()->get(_path)) {
+ }
+
+ if (_engine.store()->get(_path)) {
return Event::pre_process_done(Status::EXISTS, _path);
}
@@ -104,10 +108,14 @@ CreatePort::pre_process(PreProcessContext&)
Node* const parent = _engine.store()->get(parent_path);
if (!parent) {
return Event::pre_process_done(Status::PARENT_NOT_FOUND, parent_path);
- } else if (!(_graph = dynamic_cast<GraphImpl*>(parent))) {
+ }
+
+ if (!(_graph = dynamic_cast<GraphImpl*>(parent))) {
return Event::pre_process_done(Status::INVALID_PARENT, parent_path);
- } else if (!_graph->parent() && _engine.activated() &&
- !_engine.driver()->dynamic_ports()) {
+ }
+
+ if (!_graph->parent() && _engine.activated() &&
+ !_engine.driver()->dynamic_ports()) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index 2c6a50c8..88826a23 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -155,12 +155,15 @@ get_file_node(LilvWorld* lworld, const URIs& uris, const Atom& value)
{
if (value.type() == uris.atom_Path) {
return lilv_new_file_uri(lworld, nullptr, value.ptr<char>());
- } else if (uris.forge.is_uri(value)) {
+ }
+
+ if (uris.forge.is_uri(value)) {
const std::string str = uris.forge.str(value, false);
if (str.substr(0, 5) == "file:") {
return lilv_new_uri(lworld, value.ptr<char>());
}
}
+
return nullptr;
}
@@ -205,9 +208,9 @@ Delta::pre_process(PreProcessContext& ctx)
if ((_preset = block->save_preset(_subject, _properties))) {
return Event::pre_process_done(Status::SUCCESS);
- } else {
- return Event::pre_process_done(Status::FAILURE);
}
+
+ return Event::pre_process_done(Status::FAILURE);
}
std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index b600df4f..c20ed9a8 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -158,7 +158,9 @@ Disconnect::pre_process(PreProcessContext& ctx)
if (!_graph) {
return Event::pre_process_done(Status::INTERNAL_ERROR, _msg.head);
- } else if (!_graph->has_arc(tail, head)) {
+ }
+
+ if (!_graph->has_arc(tail, head)) {
return Event::pre_process_done(Status::NOT_FOUND, _msg.head);
}
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index ff801c06..bd59e19d 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -58,9 +58,13 @@ Get::pre_process(PreProcessContext&)
if (uri == "ingen:/plugins") {
_plugins = _engine.block_factory()->plugins();
return Event::pre_process_done(Status::SUCCESS);
- } else if (uri == "ingen:/engine") {
+ }
+
+ if (uri == "ingen:/engine") {
return Event::pre_process_done(Status::SUCCESS);
- } else if (uri_is_path(uri)) {
+ }
+
+ if (uri_is_path(uri)) {
if ((_object = _engine.store()->get(uri_to_path(uri)))) {
const BlockImpl* block = nullptr;
const GraphImpl* graph = nullptr;
@@ -77,12 +81,14 @@ Get::pre_process(PreProcessContext&)
return Event::pre_process_done(Status::SUCCESS);
}
return Event::pre_process_done(Status::NOT_FOUND, uri);
- } else if ((_plugin = _engine.block_factory()->plugin(uri))) {
+ }
+
+ if ((_plugin = _engine.block_factory()->plugin(uri))) {
_response.put_plugin(_plugin);
return Event::pre_process_done(Status::SUCCESS);
- } else {
- return Event::pre_process_done(Status::NOT_FOUND, uri);
}
+
+ return Event::pre_process_done(Status::NOT_FOUND, uri);
}
void
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 6f538ddc..c1dd4e95 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -495,7 +495,9 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
if (!map) {
lv2_log_error(&logger, "host did not provide URI map feature\n");
return nullptr;
- } else if (!unmap) {
+ }
+
+ if (!unmap) {
lv2_log_error(&logger, "host did not provide URI unmap feature\n");
return nullptr;
}