From 9800844b41eb32c612ceb7ea272edca9bde1a17e Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Fri, 12 Apr 2019 19:38:16 +0200 Subject: caja-location-dialog: Fix 'cppcheck' and 'clang' warnings Fixes 'cppcheck' warnings: [src/caja-location-dialog.c:229] -> [src/caja-location-dialog.c:237]: (warning) Either the condition 'window' is redundant or there is possible null pointer dereference: window. [src/caja-location-dialog.c:224]: (style) The scope of the variable 'formatted_location' can be reduced. Fixes Clang static analyzer warning: caja-location-dialog.c:237:12: warning: Access to field 'details' results in a dereference of a null pointer (loaded from variable 'window') slot = window->details->active_pane->active_slot; ^~~~~~~~~~~~~~~ --- src/caja-location-dialog.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/caja-location-dialog.c b/src/caja-location-dialog.c index e207a1ef..83e87132 100644 --- a/src/caja-location-dialog.c +++ b/src/caja-location-dialog.c @@ -214,11 +214,9 @@ caja_location_dialog_init (CajaLocationDialog *dialog) GtkWidget * caja_location_dialog_new (CajaWindow *window) { - CajaWindowSlot *slot; CajaLocationDialog *loc_dialog; GtkWidget *dialog; GFile *location; - char *formatted_location; dialog = gtk_widget_new (CAJA_TYPE_LOCATION_DIALOG, NULL); loc_dialog = CAJA_LOCATION_DIALOG (dialog); @@ -229,13 +227,15 @@ caja_location_dialog_new (CajaWindow *window) gtk_window_set_screen (GTK_WINDOW (dialog), gtk_window_get_screen (GTK_WINDOW (window))); loc_dialog->details->window = window; + location = window->details->active_pane->active_slot->location; } + else + location = NULL; - slot = window->details->active_pane->active_slot; - - location = slot->location; if (location != NULL) { + char *formatted_location; + if (CAJA_IS_DESKTOP_WINDOW (window)) { formatted_location = g_strdup_printf ("%s/", g_get_home_dir ()); -- cgit v1.2.1