diff --git a/src/common/import_session.c b/src/common/import_session.c index 69d8e115e2c2..6024e49bc710 100644 --- a/src/common/import_session.c +++ b/src/common/import_session.c @@ -65,8 +65,6 @@ static void _import_session_cleanup_filmroll(dt_import_session_t *self) static gboolean _import_session_initialize_filmroll(dt_import_session_t *self, const char *path) { - int32_t film_id; - /* cleanup of previously used filmroll */ _import_session_cleanup_filmroll(self); @@ -80,7 +78,7 @@ static gboolean _import_session_initialize_filmroll(dt_import_session_t *self, c /* open one or initialize a filmroll for the session */ self->film = (dt_film_t *)g_malloc0(sizeof(dt_film_t)); - film_id = dt_film_new(self->film, path); + const int32_t film_id = dt_film_new(self->film, path); if(film_id == 0) { fprintf(stderr, "[import_session] Failed to initialize film roll.\n"); @@ -250,16 +248,13 @@ const char *dt_import_session_name(struct dt_import_session_t *self) */ const char *dt_import_session_filename(struct dt_import_session_t *self, gboolean use_filename) { - const char *path; - char *fname, *previous_fname; - gchar *pattern; - gchar *result_fname; + gchar *result_fname = NULL; /* expand next filename */ g_free((void *)self->current_filename); self->current_filename = NULL; - pattern = _import_session_filename_pattern(); + char *pattern = _import_session_filename_pattern(); if(pattern == NULL) { fprintf(stderr, "[import_session] Failed to get session filaname pattern.\n"); @@ -267,14 +262,15 @@ const char *dt_import_session_filename(struct dt_import_session_t *self, gboolea } /* verify that expanded path and filename yields a unique file */ - path = dt_import_session_path(self, TRUE); + const char *path = dt_import_session_path(self, TRUE); if(use_filename) result_fname = g_strdup(self->vp->filename); else result_fname = dt_variables_expand(self->vp, pattern, TRUE); - previous_fname = fname = g_build_path(G_DIR_SEPARATOR_S, path, result_fname, (char *)NULL); + char *fname = g_build_path(G_DIR_SEPARATOR_S, path, result_fname, (char *)NULL); + char *previous_fname = fname; if(g_file_test(fname, G_FILE_TEST_EXISTS) == TRUE) { fprintf(stderr, "[import_session] File %s exists.\n", fname); @@ -313,8 +309,6 @@ const char *dt_import_session_filename(struct dt_import_session_t *self, gboolea static const char *_import_session_path(struct dt_import_session_t *self, gboolean current) { - gchar *pattern; - char *new_path; const gboolean currentok = dt_util_test_writable_dir(self->current_path); fprintf(stderr, " _import_session_path testing `%s' %i", self->current_path, currentok); @@ -327,14 +321,14 @@ static const char *_import_session_path(struct dt_import_session_t *self, gboole return NULL; } /* check if expanded path differs from current */ - pattern = _import_session_path_pattern(); + gchar *pattern = _import_session_path_pattern(); if(pattern == NULL) { fprintf(stderr, "[import_session] Failed to get session path pattern.\n"); return NULL; } - new_path = dt_variables_expand(self->vp, pattern, FALSE); + char *new_path = dt_variables_expand(self->vp, pattern, FALSE); g_free(pattern); /* did the session path change ? */