From 784dc03a78dc338b45111ebdca45371dfaaa6fa9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 23 Feb 2010 18:45:26 +0000 Subject: Fix various code issues discovered by cppcheck. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2484 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/HTTPClientReceiver.cpp | 2 +- src/client/HTTPClientReceiver.hpp | 2 +- src/client/ThreadedSigClientInterface.cpp | 2 -- src/client/ThreadedSigClientInterface.hpp | 1 - src/engine/Buffer.hpp | 1 + src/engine/HTTPClientSender.hpp | 1 + src/engine/InputPort.cpp | 7 ------- src/engine/InputPort.hpp | 1 - src/engine/ObjectBuffer.cpp | 6 ++++++ src/engine/ObjectBuffer.hpp | 1 + src/engine/PostProcessor.cpp | 6 ++++++ src/engine/PostProcessor.hpp | 1 + src/engine/events/Connect.cpp | 2 ++ src/engine/events/SendBinding.hpp | 3 ++- src/engine/events/SendPortActivity.hpp | 3 ++- src/engine/events/SendPortValue.hpp | 3 ++- src/engine/events/SetMetadata.hpp | 1 - src/engine/ingen.lv2/ingen_lv2.cpp | 1 + src/gui/App.cpp | 3 +++ src/gui/NodeMenu.cpp | 4 ++-- src/gui/NodeMenu.hpp | 4 ++-- src/gui/NodeModule.cpp | 6 +----- src/gui/PatchTreeWindow.hpp | 3 ++- src/gui/PortPropertiesWindow.cpp | 8 ++------ src/gui/PortPropertiesWindow.hpp | 2 -- src/module/World.hpp | 2 +- src/shared/OSCSender.cpp | 3 ++- 27 files changed, 42 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp index ffa142a5..72d5a369 100644 --- a/src/client/HTTPClientReceiver.cpp +++ b/src/client/HTTPClientReceiver.cpp @@ -62,7 +62,7 @@ HTTPClientReceiver::~HTTPClientReceiver() } -HTTPClientReceiver::Listener::Listener(HTTPClientReceiver* receiver, const std::string uri) +HTTPClientReceiver::Listener::Listener(HTTPClientReceiver* receiver, const std::string& uri) : _uri(uri) , _receiver(receiver) { diff --git a/src/client/HTTPClientReceiver.hpp b/src/client/HTTPClientReceiver.hpp index 63727dcb..7df87229 100644 --- a/src/client/HTTPClientReceiver.hpp +++ b/src/client/HTTPClientReceiver.hpp @@ -56,7 +56,7 @@ private: class Listener : public Raul::Thread { public: - Listener(HTTPClientReceiver* receiver, const std::string uri); + Listener(HTTPClientReceiver* receiver, const std::string& uri); ~Listener(); void _run(); private: diff --git a/src/client/ThreadedSigClientInterface.cpp b/src/client/ThreadedSigClientInterface.cpp index 56eeddf6..e89d669e 100644 --- a/src/client/ThreadedSigClientInterface.cpp +++ b/src/client/ThreadedSigClientInterface.cpp @@ -33,8 +33,6 @@ namespace Client { void ThreadedSigClientInterface::push_sig(Closure ev) { - _attached = true; - bool success = false; while (!success) { success = _sigs.push(ev); diff --git a/src/client/ThreadedSigClientInterface.hpp b/src/client/ThreadedSigClientInterface.hpp index 6a9cffdd..028d075f 100644 --- a/src/client/ThreadedSigClientInterface.hpp +++ b/src/client/ThreadedSigClientInterface.hpp @@ -118,7 +118,6 @@ private: Glib::Cond _cond; Raul::SRSWQueue _sigs; - bool _attached; sigc::slot bundle_begin_slot; sigc::slot bundle_end_slot; diff --git a/src/engine/Buffer.hpp b/src/engine/Buffer.hpp index b6d8b722..0a9d59c2 100644 --- a/src/engine/Buffer.hpp +++ b/src/engine/Buffer.hpp @@ -41,6 +41,7 @@ public: : _factory(bufs) , _type(type) , _size(size) + , _next(NULL) , _refs(0) {} diff --git a/src/engine/HTTPClientSender.hpp b/src/engine/HTTPClientSender.hpp index c34decad..1f2863e4 100644 --- a/src/engine/HTTPClientSender.hpp +++ b/src/engine/HTTPClientSender.hpp @@ -45,6 +45,7 @@ class HTTPClientSender public: HTTPClientSender(Engine& engine) : _engine(engine) + , _enabled(true) {} bool enabled() const { return _enabled; } diff --git a/src/engine/InputPort.cpp b/src/engine/InputPort.cpp index 04573a1a..f4fd3620 100644 --- a/src/engine/InputPort.cpp +++ b/src/engine/InputPort.cpp @@ -226,12 +226,5 @@ InputPort::post_process(Context& context) } -bool -InputPort::is_silent() const -{ - return (_connections.size() == 0 && _type == PortType::AUDIO); -} - - } // namespace Ingen diff --git a/src/engine/InputPort.hpp b/src/engine/InputPort.hpp index 21cf3372..44f82370 100644 --- a/src/engine/InputPort.hpp +++ b/src/engine/InputPort.hpp @@ -78,7 +78,6 @@ public: bool is_input() const { return true; } bool is_output() const { return false; } - bool is_silent() const; protected: size_t _num_connections; ///< Pre-process thread diff --git a/src/engine/ObjectBuffer.cpp b/src/engine/ObjectBuffer.cpp index e568f541..c905826d 100644 --- a/src/engine/ObjectBuffer.cpp +++ b/src/engine/ObjectBuffer.cpp @@ -59,6 +59,12 @@ ObjectBuffer::ObjectBuffer(BufferFactory& bufs, size_t capacity) } +ObjectBuffer::~ObjectBuffer() +{ + free(_buf); +} + + void ObjectBuffer::clear() { diff --git a/src/engine/ObjectBuffer.hpp b/src/engine/ObjectBuffer.hpp index 30b1029c..7d6d08e1 100644 --- a/src/engine/ObjectBuffer.hpp +++ b/src/engine/ObjectBuffer.hpp @@ -30,6 +30,7 @@ class Context; class ObjectBuffer : public Buffer { public: ObjectBuffer(BufferFactory& bufs, size_t capacity); + ~ObjectBuffer(); void clear(); diff --git a/src/engine/PostProcessor.cpp b/src/engine/PostProcessor.cpp index de073f1a..067c00ba 100644 --- a/src/engine/PostProcessor.cpp +++ b/src/engine/PostProcessor.cpp @@ -42,6 +42,12 @@ PostProcessor::PostProcessor(Engine& engine, size_t queue_size) } +PostProcessor::~PostProcessor() +{ + free(_event_buffer); +} + + void PostProcessor::process() { diff --git a/src/engine/PostProcessor.hpp b/src/engine/PostProcessor.hpp index 6450d10a..e35f75a5 100644 --- a/src/engine/PostProcessor.hpp +++ b/src/engine/PostProcessor.hpp @@ -43,6 +43,7 @@ class PostProcessor { public: PostProcessor(Engine& engine, size_t queue_size); + ~PostProcessor(); /** Push a list of events on to the process queue, realtime-safe, not thread-safe. */ inline void append(Raul::List* l) { _events.append(*l); } diff --git a/src/engine/events/Connect.cpp b/src/engine/events/Connect.cpp index 6d096bbd..fac11965 100644 --- a/src/engine/events/Connect.cpp +++ b/src/engine/events/Connect.cpp @@ -49,6 +49,8 @@ Connect::Connect(Engine& engine, SharedPtr request, SampleCount timesta , _patch(NULL) , _src_port(NULL) , _dst_port(NULL) + , _src_output_port(NULL) + , _dst_input_port(NULL) , _compiled_patch(NULL) , _patch_listnode(NULL) , _port_listnode(NULL) diff --git a/src/engine/events/SendBinding.hpp b/src/engine/events/SendBinding.hpp index 837d3463..b11ecfd2 100644 --- a/src/engine/events/SendBinding.hpp +++ b/src/engine/events/SendBinding.hpp @@ -65,10 +65,11 @@ public: } } - inline void operator=(const SendBinding& ev) { + inline SendBinding& operator=(const SendBinding& ev) { _port = ev._port; _type = ev._type; _num = ev._num; + return *this; } void post_process(); diff --git a/src/engine/events/SendPortActivity.hpp b/src/engine/events/SendPortActivity.hpp index 4481d8fc..61e0113a 100644 --- a/src/engine/events/SendPortActivity.hpp +++ b/src/engine/events/SendPortActivity.hpp @@ -51,8 +51,9 @@ public: { } - inline void operator=(const SendPortActivity& ev) { + inline SendPortActivity& operator=(const SendPortActivity& ev) { _port = ev._port; + return *this; } void post_process(); diff --git a/src/engine/events/SendPortValue.hpp b/src/engine/events/SendPortValue.hpp index 8cbb3cbe..2b390832 100644 --- a/src/engine/events/SendPortValue.hpp +++ b/src/engine/events/SendPortValue.hpp @@ -58,11 +58,12 @@ public: { } - inline void operator=(const SendPortValue& ev) { + inline SendPortValue& operator=(const SendPortValue& ev) { _port = ev._port; _omni = ev._omni; _voice_num = ev._voice_num; _value = ev._value; + return *this; } void post_process(); diff --git a/src/engine/events/SetMetadata.hpp b/src/engine/events/SetMetadata.hpp index ee7d9d42..c13505cc 100644 --- a/src/engine/events/SetMetadata.hpp +++ b/src/engine/events/SetMetadata.hpp @@ -114,7 +114,6 @@ private: std::string _error_predicate; bool _create; bool _is_meta; - bool _success; SharedPtr _old_bindings; }; diff --git a/src/engine/ingen.lv2/ingen_lv2.cpp b/src/engine/ingen.lv2/ingen_lv2.cpp index 3ff285e5..fb145c53 100644 --- a/src/engine/ingen.lv2/ingen_lv2.cpp +++ b/src/engine/ingen.lv2/ingen_lv2.cpp @@ -40,6 +40,7 @@ struct IngenLV2Driver : public Ingen::Driver { , _buffer_size(buffer_size) , _sample_rate(sample_rate) , _frame_time(0) + , _root_patch(NULL) {} void activate() {} diff --git a/src/gui/App.cpp b/src/gui/App.cpp index c2cde0ed..3bf45761 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -99,8 +99,11 @@ App::App(Ingen::Shared::World* world) App::~App() { + delete _configuration; + delete _window_factory; } + void App::init(Ingen::Shared::World* world) { diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index aed7650c..be5d645b 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -170,7 +170,7 @@ NodeMenu::on_menu_disconnect() void -NodeMenu::on_preset_activated(const std::string uri) +NodeMenu::on_preset_activated(const std::string& uri) { #ifdef HAVE_SLV2 const NodeModel* const node = (NodeModel*)_object.get(); @@ -197,7 +197,7 @@ NodeMenu::on_preset_activated(const std::string uri) bool -NodeMenu::on_preset_clicked(const std::string uri, GdkEventButton* ev) +NodeMenu::on_preset_clicked(const std::string& uri, GdkEventButton* ev) { on_preset_activated(uri); return false; diff --git a/src/gui/NodeMenu.hpp b/src/gui/NodeMenu.hpp index 1698e597..8a92c6b5 100644 --- a/src/gui/NodeMenu.hpp +++ b/src/gui/NodeMenu.hpp @@ -53,8 +53,8 @@ protected: void on_menu_disconnect(); void on_menu_embed_gui(); void on_menu_randomize(); - void on_preset_activated(const std::string uri); - bool on_preset_clicked(const std::string uri, GdkEventButton* ev); + void on_preset_activated(const std::string& uri); + bool on_preset_clicked(const std::string& uri, GdkEventButton* ev); Gtk::MenuItem* _controls_menuitem; Gtk::MenuItem* _popup_gui_menuitem; diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 68f66c70..03182942 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -66,11 +66,7 @@ NodeModule::NodeModule(boost::shared_ptr canvas, SharedPtrcontrol_window(_node); - - if (win) { - // Should remove from window factory via signal - delete win; - } + delete win; // Will be removed from window factory via signal } diff --git a/src/gui/PatchTreeWindow.hpp b/src/gui/PatchTreeWindow.hpp index b4f6ec2f..d3286653 100644 --- a/src/gui/PatchTreeWindow.hpp +++ b/src/gui/PatchTreeWindow.hpp @@ -88,7 +88,8 @@ class PatchTreeView : public Gtk::TreeView { public: PatchTreeView(BaseObjectType* cobject, const Glib::RefPtr& xml) - : Gtk::TreeView(cobject) + : Gtk::TreeView(cobject) + , _window(NULL) {} void set_window(PatchTreeWindow* win) { _window = win; } diff --git a/src/gui/PortPropertiesWindow.cpp b/src/gui/PortPropertiesWindow.cpp index 7dd5efe2..c4ffc222 100644 --- a/src/gui/PortPropertiesWindow.cpp +++ b/src/gui/PortPropertiesWindow.cpp @@ -35,7 +35,8 @@ namespace GUI { PortPropertiesWindow::PortPropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr& xml) : Window(cobject) - //, _enable_signal(false) + , _initial_min(0.0f) + , _initial_max(1.0f) { xml->get_widget("port_properties_min_spinner", _min_spinner); xml->get_widget("port_properties_max_spinner", _max_spinner); @@ -86,8 +87,6 @@ PortPropertiesWindow::present(SharedPtr pm) _connections.push_back(pm->signal_property.connect( sigc::mem_fun(this, &PortPropertiesWindow::property_changed))); - //_enable_signal = true; - Gtk::Window::present(); } @@ -96,7 +95,6 @@ void PortPropertiesWindow::property_changed(const URI& key, const Atom& value) { const Shared::LV2URIMap& uris = App::instance().uris(); - //_enable_signal = false; if (value.type() == Atom::FLOAT) { if (key == uris.lv2_minimum) @@ -104,8 +102,6 @@ PortPropertiesWindow::property_changed(const URI& key, const Atom& value) else if (key == uris.lv2_maximum) _max_spinner->set_value(value.get_float()); } - - //_enable_signal = true; } diff --git a/src/gui/PortPropertiesWindow.hpp b/src/gui/PortPropertiesWindow.hpp index 2e14976f..ce52cb8e 100644 --- a/src/gui/PortPropertiesWindow.hpp +++ b/src/gui/PortPropertiesWindow.hpp @@ -49,8 +49,6 @@ private: void ok(); void cancel(); - //bool _enable_signal; - float _initial_min; float _initial_max; diff --git a/src/module/World.hpp b/src/module/World.hpp index 9f962af1..fcb48845 100644 --- a/src/module/World.hpp +++ b/src/module/World.hpp @@ -53,7 +53,7 @@ class LV2URIMap; * set World::serialiser and World::parser to valid objects. */ struct World { - World() : conf(0) {} + World() : argc(0), argv(0), conf(0), rdf_world(0), slv2_world(0), lv2_features(0) {} bool load(const char* name); void unload_all(); diff --git a/src/shared/OSCSender.cpp b/src/shared/OSCSender.cpp index b675265a..3380b181 100644 --- a/src/shared/OSCSender.cpp +++ b/src/shared/OSCSender.cpp @@ -30,7 +30,8 @@ namespace Shared { OSCSender::OSCSender() - : _transfer(NULL) + : _send_state(Immediate) + , _transfer(NULL) , _address(NULL) , _enabled(true) { -- cgit v1.2.1