Remove redundant conditions

As mentioned in C++ Core Guidelines ES.87.
This commit is contained in:
Robbert van der Helm
2020-06-05 22:18:40 +02:00
parent 047163c6f5
commit ff298f3f46
4 changed files with 12 additions and 12 deletions
+3 -3
View File
@@ -39,7 +39,7 @@ class DefaultDataConverter {
const int /*index*/, const int /*index*/,
const intptr_t /*value*/, const intptr_t /*value*/,
const void* data) { const void* data) {
if (data == nullptr) { if (!data) {
return nullptr; return nullptr;
} }
@@ -355,7 +355,7 @@ auto passthrough_event(AEffect* plugin, F callback) {
// `effEditOpen()` I can assume there are plugins that don't // `effEditOpen()` I can assume there are plugins that don't
// handle this correctly. // handle this correctly.
VstRect* editor_rect = *static_cast<VstRect**>(data); VstRect* editor_rect = *static_cast<VstRect**>(data);
if (editor_rect == nullptr) { if (!editor_rect) {
return nullptr; return nullptr;
} }
@@ -369,7 +369,7 @@ auto passthrough_event(AEffect* plugin, F callback) {
// host doesn't support this. // host doesn't support this.
const auto time_info = const auto time_info =
reinterpret_cast<const VstTimeInfo*>(return_value); reinterpret_cast<const VstTimeInfo*>(return_value);
if (time_info == nullptr) { if (!time_info) {
return nullptr; return nullptr;
} else { } else {
return *time_info; return *time_info;
+1 -1
View File
@@ -50,7 +50,7 @@ Configuration::Configuration(const fs::path& config_path,
// If the table is missing some fields then they will simply be left at // If the table is missing some fields then they will simply be left at
// their defaults // their defaults
if (toml::table* config = value.as_table(); config != nullptr) { if (toml::table* config = value.as_table()) {
group = (*config)["group"].value<std::string>(); group = (*config)["group"].value<std::string>();
} }
+6 -6
View File
@@ -58,7 +58,7 @@ uint32_t WINAPI handle_process_replacing_proxy(void*);
Vst2Bridge& get_bridge_instance(const AEffect* plugin) { Vst2Bridge& get_bridge_instance(const AEffect* plugin) {
// This is needed during the initialization of the plugin since we can only // This is needed during the initialization of the plugin since we can only
// add our own pointer after it's done initializing // add our own pointer after it's done initializing
if (current_bridge_instance != nullptr) { if (current_bridge_instance) {
return *current_bridge_instance; return *current_bridge_instance;
} }
@@ -77,7 +77,7 @@ Vst2Bridge::Vst2Bridge(boost::asio::io_context& main_context,
host_vst_parameters(io_context), host_vst_parameters(io_context),
host_vst_process_replacing(io_context) { host_vst_process_replacing(io_context) {
// Got to love these C APIs // Got to love these C APIs
if (plugin_handle == nullptr) { if (!plugin_handle) {
throw std::runtime_error("Could not load the Windows .dll file at '" + throw std::runtime_error("Could not load the Windows .dll file at '" +
plugin_dll_path + "'"); plugin_dll_path + "'");
} }
@@ -90,11 +90,11 @@ Vst2Bridge::Vst2Bridge(boost::asio::io_context& main_context,
reinterpret_cast<VstEntryPoint>(reinterpret_cast<size_t>( reinterpret_cast<VstEntryPoint>(reinterpret_cast<size_t>(
GetProcAddress(plugin_handle.get(), name))); GetProcAddress(plugin_handle.get(), name)));
if (vst_entry_point != nullptr) { if (vst_entry_point) {
break; break;
} }
} }
if (vst_entry_point == nullptr) { if (!vst_entry_point) {
throw std::runtime_error( throw std::runtime_error(
"Could not find a valid VST entry point for '" + plugin_dll_path + "Could not find a valid VST entry point for '" + plugin_dll_path +
"'."); "'.");
@@ -116,7 +116,7 @@ Vst2Bridge::Vst2Bridge(boost::asio::io_context& main_context,
std::lock_guard lock(current_bridge_instance_mutex); std::lock_guard lock(current_bridge_instance_mutex);
current_bridge_instance = this; current_bridge_instance = this;
plugin = vst_entry_point(host_callback_proxy); plugin = vst_entry_point(host_callback_proxy);
if (plugin == nullptr) { if (!plugin) {
throw std::runtime_error("VST plugin at '" + plugin_dll_path + throw std::runtime_error("VST plugin at '" + plugin_dll_path +
"' failed to initialize."); "' failed to initialize.");
} }
@@ -301,7 +301,7 @@ void Vst2Bridge::handle_process_replacing() {
// Any plugin made in the last fifteen years or so should // Any plugin made in the last fifteen years or so should
// support `processReplacing`. In the off chance it does not we // support `processReplacing`. In the off chance it does not we
// can just emulate this behavior ourselves. // can just emulate this behavior ourselves.
if (plugin->processReplacing != nullptr) { if (plugin->processReplacing) {
plugin->processReplacing(plugin, inputs.data(), plugin->processReplacing(plugin, inputs.data(),
outputs.data(), outputs.data(),
request.sample_frames); request.sample_frames);
+2 -2
View File
@@ -258,7 +258,7 @@ LRESULT CALLBACK window_proc(HWND handle,
reinterpret_cast<CREATESTRUCT*>(lParam); reinterpret_cast<CREATESTRUCT*>(lParam);
const auto editor = const auto editor =
static_cast<Editor*>(window_parameters->lpCreateParams); static_cast<Editor*>(window_parameters->lpCreateParams);
if (editor == nullptr) { if (!editor) {
break; break;
} }
@@ -272,7 +272,7 @@ LRESULT CALLBACK window_proc(HWND handle,
case WM_TIMER: { case WM_TIMER: {
auto editor = reinterpret_cast<Editor*>( auto editor = reinterpret_cast<Editor*>(
GetWindowLongPtr(handle, GWLP_USERDATA)); GetWindowLongPtr(handle, GWLP_USERDATA));
if (editor == nullptr || wParam != idle_timer_id) { if (!editor || wParam != idle_timer_id) {
break; break;
} }