At this point, in "gui.c", we only consume the "all_disks" and
"all_removable" global variables for populating the conversion dialog,
when said dialog is first created. Eliminate those global variable
references, and pass them down instead as function parameters, via main()
-> gui_conversion() -> create_conversion_dialog() -> { populate_disks(),
populate_removable() }.

No observable changes.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2124538
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 p2v.h  |  4 ++-
 gui.c  | 31 ++++++++++++--------
 main.c |  3 +-
 3 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/p2v.h b/p2v.h
index e7f0b9e467fd..d48b4fcc6611 100644
--- a/p2v.h
+++ b/p2v.h
@@ -94,7 +94,9 @@ extern void update_config_from_kernel_cmdline (struct config 
*config, char **cmd
 extern void kernel_conversion (struct config *, char **cmdline, int 
cmdline_source);
 
 /* gui.c */
-extern void gui_conversion (struct config *);
+extern void gui_conversion (struct config *config,
+                            const char * const *disks,
+                            const char * const *removable);
 
 /* conversion.c */
 struct data_conn {          /* Data per NBD connection / physical disk. */
diff --git a/gui.c b/gui.c
index bbd793c70d95..2cf30943bb5e 100644
--- a/gui.c
+++ b/gui.c
@@ -101,7 +101,9 @@
 #endif
 
 static void create_connection_dialog (struct config *);
-static void create_conversion_dialog (struct config *);
+static void create_conversion_dialog (struct config *config,
+                                      const char * const *disks,
+                                      const char * const *removable);
 static void create_running_dialog (void);
 static void show_connection_dialog (void);
 static void show_conversion_dialog (void);
@@ -160,11 +162,13 @@ static const char gplv2plus[] =
  * Note that C<gtk_init> etc have already been called in C<main>.
  */
 void
-gui_conversion (struct config *config)
+gui_conversion (struct config *config,
+                const char * const *disks,
+                const char * const *removable)
 {
   /* Create the dialogs. */
   create_connection_dialog (config);
-  create_conversion_dialog (config);
+  create_conversion_dialog (config, disks, removable);
   create_running_dialog ();
 
   /* Start by displaying the connection dialog. */
@@ -680,8 +684,10 @@ connection_next_clicked (GtkWidget *w, gpointer data)
 /*----------------------------------------------------------------------*/
 /* Conversion dialog. */
 
-static void populate_disks (GtkTreeView *disks_list_p);
-static void populate_removable (GtkTreeView *removable_list_p);
+static void populate_disks (GtkTreeView *disks_list_p,
+                            const char * const *disks);
+static void populate_removable (GtkTreeView *removable_list_p,
+                                const char * const *removable);
 static void populate_interfaces (GtkTreeView *interfaces_list_p);
 static void toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer 
data);
 static void network_edited_callback (GtkCellRendererToggle *cell, gchar 
*path_str, gchar *new_text, gpointer data);
@@ -728,7 +734,9 @@ enum {
  * C<show_conversion_dialog>.
  */
 static void
-create_conversion_dialog (struct config *config)
+create_conversion_dialog (struct config *config,
+                          const char * const *disks,
+                          const char * const *removable)
 {
   GtkWidget *back;
   GtkWidget *hbox, *left_vbox, *right_vbox;
@@ -925,7 +933,7 @@ create_conversion_dialog (struct config *config)
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (disks_sw),
                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
   disks_list = gtk_tree_view_new ();
-  populate_disks (GTK_TREE_VIEW (disks_list));
+  populate_disks (GTK_TREE_VIEW (disks_list), disks);
   scrolled_window_add_with_viewport (disks_sw, disks_list);
   gtk_container_add (GTK_CONTAINER (disks_frame), disks_sw);
 
@@ -936,7 +944,7 @@ create_conversion_dialog (struct config *config)
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (removable_sw),
                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
   removable_list = gtk_tree_view_new ();
-  populate_removable (GTK_TREE_VIEW (removable_list));
+  populate_removable (GTK_TREE_VIEW (removable_list), removable);
   scrolled_window_add_with_viewport (removable_sw,  removable_list);
   gtk_container_add (GTK_CONTAINER (removable_frame), removable_sw);
 
@@ -1097,9 +1105,8 @@ repopulate_output_combo (struct config *config)
  * Populate the C<Fixed hard disks> treeview.
  */
 static void
-populate_disks (GtkTreeView *disks_list_p)
+populate_disks (GtkTreeView *disks_list_p, const char * const *disks)
 {
-  const char * const *disks = (const char **)all_disks;
   GtkListStore *disks_store;
   GtkCellRenderer *disks_col_convert, *disks_col_device;
   GtkTreeIter iter;
@@ -1171,9 +1178,9 @@ populate_disks (GtkTreeView *disks_list_p)
  * Populate the C<Removable media> treeview.
  */
 static void
-populate_removable (GtkTreeView *removable_list_p)
+populate_removable (GtkTreeView *removable_list_p,
+                    const char * const *removable)
 {
-  const char * const *removable = (const char **)all_removable;
   GtkListStore *removable_store;
   GtkCellRenderer *removable_col_convert, *removable_col_device;
   GtkTreeIter iter;
diff --git a/main.c b/main.c
index 6ebb71ce4314..86820dd27e08 100644
--- a/main.c
+++ b/main.c
@@ -256,7 +256,8 @@ main (int argc, char *argv[])
       error (EXIT_FAILURE, 0,
              _("gtk_init_check returned false, indicating that\n"
                "a GUI is not possible on this host.  Check X11, $DISPLAY 
etc."));
-    gui_conversion (config);
+    gui_conversion (config, (const char **)all_disks,
+                    (const char **)all_removable);
   }
 
   guestfs_int_free_string_list (cmdline);

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to