From bbff4459368ea25f1ae1ee3452a5b5c5dcd64e06 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 16 Dec 2020 16:49:57 +0100 Subject: Isolate variable declarations and initialize all variables --- plugins/eg-metro.lv2/metro.c | 4 +++- plugins/eg-params.lv2/params.c | 10 +++++----- plugins/eg-sampler.lv2/sampler.c | 10 +++++----- plugins/eg-scope.lv2/examploscope.c | 6 +++--- plugins/eg-scope.lv2/examploscope_ui.c | 9 ++++----- 5 files changed, 20 insertions(+), 19 deletions(-) (limited to 'plugins') diff --git a/plugins/eg-metro.lv2/metro.c b/plugins/eg-metro.lv2/metro.c index 060060c..4531e1e 100644 --- a/plugins/eg-metro.lv2/metro.c +++ b/plugins/eg-metro.lv2/metro.c @@ -266,7 +266,9 @@ update_position(Metro* self, const LV2_Atom_Object* obj) const MetroURIs* uris = &self->uris; // Received new transport position/speed - LV2_Atom *beat = NULL, *bpm = NULL, *speed = NULL; + LV2_Atom* beat = NULL; + LV2_Atom* bpm = NULL; + LV2_Atom* speed = NULL; lv2_atom_object_get(obj, uris->time_barBeat, &beat, uris->time_beatsPerMinute, &bpm, diff --git a/plugins/eg-params.lv2/params.c b/plugins/eg-params.lv2/params.c index 94d34a5..cb09e83 100644 --- a/plugins/eg-params.lv2/params.c +++ b/plugins/eg-params.lv2/params.c @@ -290,7 +290,7 @@ store_prop(Params* self, LV2_URID key, const LV2_Atom* value) { - LV2_State_Status st; + LV2_State_Status st = LV2_STATE_SUCCESS; if (map_path && value->type == self->uris.atom_Path) { // Map path to abstract path for portable storage const char* path = (const char*)(value + 1); @@ -352,10 +352,10 @@ retrieve_prop(Params* self, LV2_URID key) { // Retrieve value from saved state - size_t vsize; - uint32_t vtype; - uint32_t vflags; - const void* value = retrieve(handle, key, &vsize, &vtype, &vflags); + size_t vsize = 0; + uint32_t vtype = 0; + uint32_t vflags = 0; + const void* value = retrieve(handle, key, &vsize, &vtype, &vflags); // Set plugin instance state const LV2_State_Status st = value diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c index 1ed23fa..a3b2e7d 100644 --- a/plugins/eg-sampler.lv2/sampler.c +++ b/plugins/eg-sampler.lv2/sampler.c @@ -521,11 +521,11 @@ restore(LV2_Handle instance, } // Get eg:sample from state - size_t size; - uint32_t type; - uint32_t valflags; - const void* value = retrieve(handle, self->uris.eg_sample, - &size, &type, &valflags); + size_t size = 0; + uint32_t type = 0; + uint32_t valflags = 0; + const void* value = retrieve(handle, self->uris.eg_sample, + &size, &type, &valflags); if (!value) { lv2_log_error(&self->logger, "Missing eg:sample\n"); return LV2_STATE_ERR_NO_PROPERTY; diff --git a/plugins/eg-scope.lv2/examploscope.c b/plugins/eg-scope.lv2/examploscope.c index a4f5f3f..e175804 100644 --- a/plugins/eg-scope.lv2/examploscope.c +++ b/plugins/eg-scope.lv2/examploscope.c @@ -358,9 +358,9 @@ state_restore(LV2_Handle instance, { EgScope* self = (EgScope*)instance; - size_t size; - uint32_t type; - uint32_t valflags; + size_t size = 0; + uint32_t type = 0; + uint32_t valflags = 0; const void* spp = retrieve( handle, self->uris.ui_spp, &size, &type, &valflags); diff --git a/plugins/eg-scope.lv2/examploscope_ui.c b/plugins/eg-scope.lv2/examploscope_ui.c index 33f1b0a..5e244af 100644 --- a/plugins/eg-scope.lv2/examploscope_ui.c +++ b/plugins/eg-scope.lv2/examploscope_ui.c @@ -193,8 +193,7 @@ on_expose_event(GtkWidget* widget, GdkEventExpose* ev, gpointer data) const float gain = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ui->spb_amp)); // Get cairo type for the gtk window - cairo_t* cr; - cr = gdk_cairo_create(ui->darea->window); + cairo_t* cr = gdk_cairo_create(ui->darea->window); // Limit cairo-drawing to exposed area cairo_rectangle(cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height); @@ -392,9 +391,9 @@ update_scope(EgScopeUI* ui, return; } - uint32_t idx_start; // Display pixel start - uint32_t idx_end; // Display pixel end - int overflow; // Received more audio-data than display-pixel + uint32_t idx_start = 0; // Display pixel start + uint32_t idx_end = 0; // Display pixel end + int overflow = 0; // Received more audio-data than display-pixel // Process this channel's audio-data for display ScoChan* chn = &ui->chn[channel]; -- cgit v1.2.1