From 0aea3dae1101e6f21f4ab51fd3301d2786b7f5c4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 1 Aug 2020 16:01:35 +0200 Subject: Fix uninitialized variables --- src/gui/GraphCanvas.cpp | 12 ++++++------ src/gui/GraphView.cpp | 9 +++++++-- src/server/Buffer.cpp | 4 ++-- src/server/BufferFactory.cpp | 4 ++-- src/server/RunContext.cpp | 2 +- src/server/UndoStack.cpp | 2 +- src/server/ingen_lv2.cpp | 6 +++--- src/server/internals/Controller.cpp | 2 +- 8 files changed, 23 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 18fd1a39..b6a8e5a2 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -324,8 +324,8 @@ GraphCanvas::remove_plugin(const URI& uri) void GraphCanvas::add_block(const SPtr& bm) { - SPtr pm = dynamic_ptr_cast(bm); - NodeModule* module; + SPtr pm = dynamic_ptr_cast(bm); + NodeModule* module = nullptr; if (pm) { module = SubgraphModule::create(*this, pm, _human_names); } else { @@ -485,8 +485,8 @@ GraphCanvas::auto_menu_position(int& x, int& y, bool& push_in) *_app.window_factory()->graph_window(_graph), 64, 64, _menu_x, _menu_y); - int origin_x; - int origin_y; + int origin_x = 0; + int origin_y = 0; widget().get_window()->get_origin(origin_x, origin_y); _menu_x += origin_x; _menu_y += origin_y; @@ -865,8 +865,8 @@ GraphCanvas::load_plugin(const WPtr& weak_plugin) void GraphCanvas::get_new_module_location(double& x, double& y) { - int scroll_x; - int scroll_y; + int scroll_x = 0; + int scroll_y = 0; get_scroll_offsets(scroll_x, scroll_y); x = scroll_x + 20; y = scroll_y + 20; diff --git a/src/gui/GraphView.cpp b/src/gui/GraphView.cpp index a4bc1400..4f76f798 100644 --- a/src/gui/GraphView.cpp +++ b/src/gui/GraphView.cpp @@ -100,9 +100,14 @@ GraphView::set_graph(const SPtr& graph) SPtr GraphView::create(App& app, const SPtr& graph) { - GraphView* result = nullptr; - Glib::RefPtr xml = WidgetFactory::create("warehouse_win"); + GraphView* result = nullptr; + Glib::RefPtr xml = WidgetFactory::create("warehouse_win"); + xml->get_widget_derived("graph_view_box", result); + if (!result) { + return nullptr; + } + result->init(app); result->set_graph(graph); return SPtr(result); diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index 5df57ce7..dfcd0a71 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -250,7 +250,7 @@ Buffer::peak(const RunContext& context) const vpeak = _mm_max_ps(vpeak, tmp); // peak = vpeak[0] - float peak; + float peak = 0.0f; _mm_store_ss(&peak, vpeak); return peak; @@ -448,7 +448,7 @@ Buffer::dump_cv(const RunContext& context) const void* Buffer::aligned_alloc(size_t size) { #ifdef HAVE_POSIX_MEMALIGN - void* buf; + void* buf = nullptr; if (!posix_memalign(static_cast(&buf), 16, size)) { memset(buf, 0, size); return buf; diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp index 657484d8..e7bb146a 100644 --- a/src/server/BufferFactory.cpp +++ b/src/server/BufferFactory.cpp @@ -116,7 +116,7 @@ BufferFactory::try_get_buffer(LV2_URID type) { std::atomic& head_ptr = free_list(type); Buffer* head = nullptr; - Buffer* next; + Buffer* next = nullptr; do { head = head_ptr.load(); if (!head) { @@ -183,7 +183,7 @@ void BufferFactory::recycle(Buffer* buf) { std::atomic& head_ptr = free_list(buf->type()); - Buffer* try_head; + Buffer* try_head = nullptr; do { try_head = head_ptr.load(); buf->_next = try_head; diff --git a/src/server/RunContext.cpp b/src/server/RunContext.cpp index b4b8156e..41d383cc 100644 --- a/src/server/RunContext.cpp +++ b/src/server/RunContext.cpp @@ -194,7 +194,7 @@ void RunContext::run() { while (_engine.wait_for_tasks()) { - for (Task* t; (t = _engine.steal_task(0));) { + for (Task* t = nullptr; (t = _engine.steal_task(0));) { t->run(*this); } } diff --git a/src/server/UndoStack.cpp b/src/server/UndoStack.cpp index d9e00075..40951468 100644 --- a/src/server/UndoStack.cpp +++ b/src/server/UndoStack.cpp @@ -40,7 +40,7 @@ int UndoStack::start_entry() { if (_depth == 0) { - time_t now; + time_t now = {}; time(&now); _stack.emplace_back(Entry(now)); } diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 03bebe80..a33fd482 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -768,9 +768,9 @@ ingen_restore(LV2_Handle instance, } LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file); - size_t size; - uint32_t type; - uint32_t valflags; + size_t size = 0; + uint32_t type = 0; + uint32_t valflags = 0; // Get abstract path to graph file const char* path = static_cast( diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp index 4c253cc1..d40fc431 100644 --- a/src/server/internals/Controller.cpp +++ b/src/server/internals/Controller.cpp @@ -154,7 +154,7 @@ ControllerNode::control(RunContext& context, uint8_t control_num, uint8_t val, F const Sample max_port_val = _max_port->buffer(0)->value_at(offset); const Sample log_port_val = _log_port->buffer(0)->value_at(offset); - Sample scaled_value; + Sample scaled_value = 0.0f; if (log_port_val > 0.0f) { // haaaaack, stupid negatives and logarithms Sample log_offset = 0; -- cgit v1.2.1