Wireshark mailing list archives
Unreachable code in ui/gtk/main_menubar.c
From: Alexis La Goutte <alexis.lagoutte () gmail com>
Date: Thu, 24 Apr 2014 08:52:35 +0200
Hi, I look warning found by Clang with -Wunreachable-code flags and found this in main_menubar.c : void menu_recent_file_write_all(FILE *rf) { GtkWidget *submenu_recent_files; GList *children; GList *child; gchar *cf_name; GList *recent_files_list, *list; submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH); if(!submenu_recent_files){ g_warning("menu_recent_file_write_all: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH"); } recent_files_list = (GList *)g_object_get_data(G_OBJECT(submenu_recent_files), "recent-files-list"); list = g_list_last(recent_files_list); while (list != NULL) { cf_name = (gchar *)list->data; if (cf_name) { if(u3_active()) fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", u3_contract_device_path(cf_name)); else fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name); } list = g_list_previous(list); } g_list_free(recent_files_list); return; /* we have to iterate backwards through the children's list, * so we get the latest item last in the file. * (don't use gtk_container_foreach() here, it will return the wrong iteration order) */ children = gtk_container_get_children(GTK_CONTAINER(submenu_recent_files)); child = g_list_last(children); while (child != NULL) { /* get capture filename from the menu item label */ cf_name = (gchar *)g_object_get_data(G_OBJECT(child->data), MENU_RECENT_FILES_KEY); if (cf_name) { if(u3_active()) fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", u3_contract_device_path(cf_name)); else fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name); } child = g_list_previous(child); } g_list_free(children); } Note the "return;" after g_list_free(recent_files_list); There is a reason to kept the children ? ___________________________________________________________________________ Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org> Archives: http://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- Unreachable code in ui/gtk/main_menubar.c Alexis La Goutte (Apr 24)