In populate_disks() and populate_removable(), use local variables called
"disks" and "removable", respectively, for most of the logic. Set
each
local at the top of the corresponding function, from the corresponding
globals "all_disks" and "all_removable". No observable changes.
Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=2124538
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
gui.c | 26 +++++++++++---------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/gui.c b/gui.c
index 82c297b0be4b..bbd793c70d95 100644
--- a/gui.c
+++ b/gui.c
@@ -1099,6 +1099,7 @@ repopulate_output_combo (struct config *config)
static void
populate_disks (GtkTreeView *disks_list_p)
{
+ const char * const *disks = (const char **)all_disks;
GtkListStore *disks_store;
GtkCellRenderer *disks_col_convert, *disks_col_device;
GtkTreeIter iter;
@@ -1107,20 +1108,20 @@ populate_disks (GtkTreeView *disks_list_p)
disks_store = gtk_list_store_new (NUM_DISKS_COLS,
G_TYPE_BOOLEAN, G_TYPE_STRING,
G_TYPE_STRING);
- if (all_disks != NULL) {
- for (i = 0; all_disks[i] != NULL; ++i) {
+ if (disks != NULL) {
+ for (i = 0; disks[i] != NULL; ++i) {
uint64_t size;
CLEANUP_FREE char *size_gb = NULL;
CLEANUP_FREE char *model = NULL;
CLEANUP_FREE char *serial = NULL;
CLEANUP_FREE char *device_descr = NULL;
- if (all_disks[i][0] != '/') { /* not using --test-disk */
- size = get_blockdev_size (all_disks[i]);
+ if (disks[i][0] != '/') { /* not using --test-disk */
+ size = get_blockdev_size (disks[i]);
if (asprintf (&size_gb, "%" PRIu64 "G", size) == -1)
error (EXIT_FAILURE, errno, "asprintf");
- model = get_blockdev_model (all_disks[i]);
- serial = get_blockdev_serial (all_disks[i]);
+ model = get_blockdev_model (disks[i]);
+ serial = get_blockdev_serial (disks[i]);
}
if (asprintf (&device_descr,
@@ -1129,7 +1130,7 @@ populate_disks (GtkTreeView *disks_list_p)
"%s %s\n"
"%s%s"
"</small>",
- all_disks[i],
+ disks[i],
size_gb ? size_gb : "", model ? model : "",
serial ? "s/n " : "", serial ? serial :
"") == -1)
error (EXIT_FAILURE, errno, "asprintf");
@@ -1137,7 +1138,7 @@ populate_disks (GtkTreeView *disks_list_p)
gtk_list_store_append (disks_store, &iter);
gtk_list_store_set (disks_store, &iter,
DISKS_COL_CONVERT, TRUE,
- DISKS_COL_HW_NAME, all_disks[i],
+ DISKS_COL_HW_NAME, disks[i],
DISKS_COL_DEVICE, device_descr,
-1);
}
@@ -1172,6 +1173,7 @@ populate_disks (GtkTreeView *disks_list_p)
static void
populate_removable (GtkTreeView *removable_list_p)
{
+ const char * const *removable = (const char **)all_removable;
GtkListStore *removable_store;
GtkCellRenderer *removable_col_convert, *removable_col_device;
GtkTreeIter iter;
@@ -1180,17 +1182,17 @@ populate_removable (GtkTreeView *removable_list_p)
removable_store = gtk_list_store_new (NUM_REMOVABLE_COLS,
G_TYPE_BOOLEAN, G_TYPE_STRING,
G_TYPE_STRING);
- if (all_removable != NULL) {
- for (i = 0; all_removable[i] != NULL; ++i) {
+ if (removable != NULL) {
+ for (i = 0; removable[i] != NULL; ++i) {
CLEANUP_FREE char *device_descr = NULL;
- if (asprintf (&device_descr, "<b>%s</b>\n",
all_removable[i]) == -1)
+ if (asprintf (&device_descr, "<b>%s</b>\n", removable[i])
== -1)
error (EXIT_FAILURE, errno, "asprintf");
gtk_list_store_append (removable_store, &iter);
gtk_list_store_set (removable_store, &iter,
REMOVABLE_COL_CONVERT, TRUE,
- REMOVABLE_COL_HW_NAME, all_removable[i],
+ REMOVABLE_COL_HW_NAME, removable[i],
REMOVABLE_COL_DEVICE, device_descr,
-1);
}