From 92ea5e5e7ef665040eb62eef9c5ae403edd9f64c Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Fri, 15 Oct 2010 18:02:22 +0000 Subject: [PATCH] fixes for more issues found --- src/sview/block_info.c | 10 +++--- src/sview/common.c | 69 +++++++++++++++++++----------------------- src/sview/defaults.c | 18 +++++------ src/sview/grid.c | 46 ++++++++++++++-------------- src/sview/job_info.c | 13 ++------ src/sview/node_info.c | 50 ++++++++++++------------------ src/sview/part_info.c | 34 ++------------------- src/sview/resv_info.c | 8 ++--- src/sview/sview.c | 14 ++++----- src/sview/sview.h | 2 +- 10 files changed, 105 insertions(+), 159 deletions(-) diff --git a/src/sview/block_info.c b/src/sview/block_info.c index b2940e09afb..2bab9194cba 100644 --- a/src/sview/block_info.c +++ b/src/sview/block_info.c @@ -90,8 +90,6 @@ enum { static char *_initial_page_opts = ",Block ID,State,JobID,User,Node Count," "Connection Type,BP List,Partition"; -static bool _set_page_opts = FALSE; - static display_data_t display_data_block[] = { {G_TYPE_INT, SORTID_POS, NULL, FALSE, EDIT_NONE, refresh_block, create_model_block, admin_edit_block}, @@ -918,12 +916,12 @@ extern void get_info_block(GtkTable *table, display_data_t *display_data) ListIterator itr = NULL; sview_block_info_t *sview_block_info_ptr = NULL; GtkTreePath *path = NULL; + static bool set_opts = FALSE; - if (!_set_page_opts) { + if (!set_opts) set_page_opts(BLOCK_PAGE, display_data_block, - SORTID_CNT, _initial_page_opts); - _set_page_opts = TRUE; - } + SORTID_CNT, _initial_page_opts); + set_opts = TRUE; /* reset */ if(!table && !display_data) { diff --git a/src/sview/common.c b/src/sview/common.c index 0c01b0970dc..2496ab2525e 100644 --- a/src/sview/common.c +++ b/src/sview/common.c @@ -681,12 +681,10 @@ extern char *delstr(char *str, char *orig) } -extern void free_switch_nodes_maps(switch_record_bitmaps_t - *sw_nodes_bitmaps_ptr) +extern void free_switch_nodes_maps( + switch_record_bitmaps_t *sw_nodes_bitmaps_ptr) { - - int i; - for (i=0;;i++, sw_nodes_bitmaps_ptr++) { + while (sw_nodes_bitmaps_ptr++) { if (!sw_nodes_bitmaps_ptr->node_bitmap) break; bit_free(sw_nodes_bitmaps_ptr->node_bitmap); @@ -708,31 +706,31 @@ extern int build_nodes_bitmap(char *node_names, bitstr_t **bitmap) g_print("..............._node_names2bitmap............%s\n", node_names); my_bitmap = (bitstr_t *) bit_alloc(g_node_info_ptr->record_count); - if (my_bitmap == NULL) { + if (!my_bitmap) { fatal("bit_alloc malloc failure"); } *bitmap = my_bitmap; - if (node_names == NULL) { + if (!node_names) { error("_node_name2bitmap: node_names is NULL"); return EINVAL; } - if ( (host_list = hostlist_create(node_names)) == NULL) { + if (!(host_list = hostlist_create(node_names))) { error("_node_name2bitmap: hostlist_create(%s) error", node_names); return EINVAL; } /*spin hostlist and map nodes into a bitmap*/ - while ( (this_node_name = hostlist_shift(host_list)) ) { - node_inx = _find_node_inx(this_node_name); //topo - if (node_inx != -1) { - bit_set(my_bitmap, (bitoff_t) (node_inx)); - } else { + while ((this_node_name = hostlist_shift(host_list))) { + node_inx = _find_node_inx(this_node_name); + free(this_node_name); + + if (node_inx == -1) continue; - } - free (this_node_name); + + bit_set(my_bitmap, (bitoff_t)node_inx); } hostlist_destroy(host_list); @@ -748,8 +746,7 @@ extern int get_topo_conf(void) if (TOPO_DEBUG) g_print("get_topo_conf\n"); - if ((g_topo_info_msg_ptr == NULL) && - slurm_load_topo(&g_topo_info_msg_ptr)) { + if (!g_topo_info_msg_ptr && slurm_load_topo(&g_topo_info_msg_ptr)) { slurm_perror ("slurm_load_topo error"); if (TOPO_DEBUG) g_print("get_topo_conf error !!\n"); @@ -765,15 +762,14 @@ extern int get_topo_conf(void) if (g_switch_nodes_maps) free_switch_nodes_maps(g_switch_nodes_maps); - g_switch_nodes_maps = xmalloc(sizeof - (sw_nodes_bitmaps) - *g_topo_info_msg_ptr->record_count); + g_switch_nodes_maps = xmalloc(sizeof(sw_nodes_bitmaps) + * g_topo_info_msg_ptr->record_count); sw_nodes_bitmaps_ptr = g_switch_nodes_maps; if (TOPO_DEBUG) g_print("_display_topology, record_count = %d\n", g_topo_info_msg_ptr->record_count); - for (i=0; i<g_topo_info_msg_ptr->record_count; + for (i=0; i < g_topo_info_msg_ptr->record_count; i++, sw_nodes_bitmaps_ptr++) { if (g_topo_info_msg_ptr->topo_array[i].nodes) { if (TOPO_DEBUG) @@ -812,7 +808,7 @@ extern int get_row_number(GtkTreeView *tree_view, GtkTreePath *path) GtkTreeIter iter; int line = 0; - if(!model) { + if (!model) { g_error("error getting the model from the tree_view"); return -1; } @@ -829,10 +825,10 @@ extern int find_col(display_data_t *display_data, int type) { int i = 0; - while(display_data++) { - if(display_data->id == -1) + while (display_data++) { + if (display_data->id == -1) break; - if(display_data->id == type) + if (display_data->id == type) return i; i++; } @@ -843,10 +839,10 @@ extern const char *find_col_name(display_data_t *display_data, int type) { int i = 0; - while(display_data++) { - if(display_data->id == -1) + while (display_data++) { + if (display_data->id == -1) break; - if(display_data->id == type) + if (display_data->id == type) return display_data->name; i++; } @@ -925,15 +921,15 @@ extern void make_fields_menu(popup_info_t *popup_win, GtkMenu *menu, } -extern void set_page_opts(int tab, display_data_t *display_data, +extern void set_page_opts(int page, display_data_t *display_data, int count, char* initial_opts) { page_opts_t *page_opts; int j= 0; - xassert(tab < PAGE_CNT); + xassert(page < PAGE_CNT); - page_opts = &working_sview_config.page_opts[tab]; + page_opts = &working_sview_config.page_opts[page]; if (!page_opts->col_list) { page_opts->def_col_list = 1; page_opts->col_list = xstrdup(initial_opts); @@ -944,13 +940,10 @@ extern void set_page_opts(int tab, display_data_t *display_data, for (j=0; j<count; j++) { if (display_data->id == -1) break; - if (!display_data->name) { - display_data++; - continue; - } - if (strstr(page_opts->col_list, display_data->name)) { + if (display_data->name + && strstr(page_opts->col_list, display_data->name)) display_data->show = TRUE; - } + display_data++; } } @@ -1637,7 +1630,7 @@ extern popup_info_t *create_popup_info(int type, int dest_type, char *title) G_CALLBACK(_frame_callback), popup_win); gtk_window_move(GTK_WINDOW(popup_win->popup), - popup_pos.x,popup_pos.y); + popup_pos.x, popup_pos.y); gtk_widget_show_all(popup_win->popup); return popup_win; } diff --git a/src/sview/defaults.c b/src/sview/defaults.c index adae92e60f0..7f9a808344c 100644 --- a/src/sview/defaults.c +++ b/src/sview/defaults.c @@ -124,7 +124,7 @@ static void _set_active_combo_defaults(GtkComboBox *combo, action = sview_config->show_hidden; break; case SORTID_SAVE_PAGE_OPTS: - action = sview_config->save_page_settings; + action = sview_config->save_page_opts; break; case SORTID_DEFAULT_PAGE: action = sview_config->default_page; @@ -239,9 +239,9 @@ static const char *_set_sview_config(sview_config_t *sview_config, case SORTID_SAVE_PAGE_OPTS: type = "Save Page Settings"; if (!strcasecmp(new_text, "yes")) - sview_config->save_page_settings = 1; + sview_config->save_page_opts = 1; else - sview_config->save_page_settings = 0; + sview_config->save_page_opts = 0; break; case SORTID_TAB_POS: type = "Tab Position"; @@ -535,9 +535,9 @@ extern int load_defaults() {"PageOptsReservation", S_P_STRING}, {"RefreshDelay", S_P_UINT16}, {"RuledTables", S_P_BOOLEAN}, + {"SavePageSettings", S_P_BOOLEAN}, {"ShowGrid", S_P_BOOLEAN}, {"ShowHidden", S_P_BOOLEAN}, - {"SavePageSettings", S_P_BOOLEAN}, {"TabPosition", S_P_STRING}, {"VisiblePages", S_P_STRING}, {NULL} @@ -605,7 +605,7 @@ extern int load_defaults() "ShowGrid", hashtbl); s_p_get_boolean(&default_sview_config.show_hidden, "ShowHidden", hashtbl); - s_p_get_boolean(&default_sview_config.save_page_settings, + s_p_get_boolean(&default_sview_config.save_page_opts, "SavePageSettings", hashtbl); s_p_get_uint32(&default_sview_config.main_width, "MainWidth", hashtbl); @@ -812,7 +812,7 @@ extern int save_defaults(bool final_save) if(rc != SLURM_SUCCESS) goto end_it; tmp_str = xstrdup_printf("SavePageSettings=%s\n", - default_sview_config.save_page_settings ? + default_sview_config.save_page_opts ? "YES" : "NO"); rc = _write_to_file(fd, tmp_str); xfree(tmp_str); @@ -843,7 +843,7 @@ extern int save_defaults(bool final_save) if (!page_opts->page_name) continue; - if (working_sview_config.save_page_settings) { + if (working_sview_config.save_page_opts) { if (page_opts->display_data) { display_data = page_opts->display_data; for (j=0; j<page_opts->count; j++) { @@ -851,7 +851,7 @@ extern int save_defaults(bool final_save) break; if (display_data->name && display_data->show) - xstrfmtcat(tmp_str2, "%s,", + xstrfmtcat(tmp_str2, ",%s", display_data->name); display_data++; } //spin the menu options ^^ @@ -1135,7 +1135,7 @@ extern int configure_defaults() apply_hidden_change = TRUE; gtk_toggle_action_set_active( default_sview_config.action_page_opts, - working_sview_config.save_page_settings); + working_sview_config.save_page_opts); sview_radio_action_set_current_value( default_sview_config.action_tab, working_sview_config.tab_pos); diff --git a/src/sview/grid.c b/src/sview/grid.c index 4686ee1f7a7..b04b84798b1 100644 --- a/src/sview/grid.c +++ b/src/sview/grid.c @@ -590,8 +590,9 @@ static int _add_button_to_list(node_info_t *node_ptr, DIM_SIZE[Z] + z; if (node_exists[i]) continue; - _build_empty_node(x, y, z, - button_processor); + _build_empty_node( + x, y, z, + button_processor); } } } @@ -661,9 +662,9 @@ static int _add_button_to_list(node_info_t *node_ptr, if (button_processor->force_row_break) { (*button_processor->coord_x) = 0; (*button_processor->coord_y)+= 2; - gtk_table_set_row_spacing(button_processor->table, - (*button_processor->coord_y)-1, - 5); + gtk_table_set_row_spacing( + button_processor->table, + (*button_processor->coord_y)-1, 5); return SLURM_SUCCESS; } @@ -685,9 +686,10 @@ static int _grid_table_by_switch(button_processor_t *button_processor, { int rc = SLURM_SUCCESS; int inx = 0, ii = 0; - button_processor->inx = &inx; switch_record_bitmaps_t *sw_nodes_bitmaps_ptr = g_switch_nodes_maps; + button_processor->inx = &inx; + /* engage if want original ListIterator itr = list_iterator_create(node_list); sview_node_info_t *sview_node_info_ptr = NULL; @@ -711,10 +713,10 @@ static int _grid_table_by_switch(button_processor_t *button_processor, j); if (!bit_test(sw_nodes_bitmaps_ptr->node_bitmap, j)) continue; - if (!working_sview_config.show_hidden) { - if(!check_part_includes_node(j)) - continue; - } + /* if (!working_sview_config.show_hidden) { */ + /* if(!check_part_includes_node(j)) */ + /* continue; */ + /* } */ if (j == last) button_processor->force_row_break = TRUE; if ((rc = _add_button_to_list( @@ -758,12 +760,12 @@ static int _grid_table_by_list(button_processor_t *button_processor, button_processor->inx = &inx; while ((sview_node_info_ptr = list_next(itr))) { - if (!working_sview_config.show_hidden) { - if (!check_part_includes_node(inx)) { - inx++; - continue; - } - } + /* if (!working_sview_config.show_hidden) { */ + /* if (!check_part_includes_node(inx)) { */ + /* inx++; */ + /* continue; */ + /* } */ + /* } */ if ((rc = _add_button_to_list( sview_node_info_ptr->node_ptr, button_processor)) != SLURM_SUCCESS) @@ -1368,12 +1370,12 @@ extern int update_grid_table(GtkTable *table, List button_list, List node_list) while ((sview_node_info_ptr = list_next(itr))) { int found = 0; - if (!working_sview_config.show_hidden) { - if(!check_part_includes_node(inx)) { - inx++; - continue; - } - } + /* if (!working_sview_config.show_hidden */ + /* && !check_part_includes_node(inx)) { */ + /* inx++; */ + /* continue; */ + /* } */ + // again: while ((button_processor.grid_button = list_next(itr2))) { if (button_processor.grid_button->inx != inx) { diff --git a/src/sview/job_info.c b/src/sview/job_info.c index 50b1f5ac64f..b8f8d08c098 100644 --- a/src/sview/job_info.c +++ b/src/sview/job_info.c @@ -177,8 +177,6 @@ enum { static char *_initial_page_opts = (",JobID,Partition,UserID,Name," "State,Time Running,Node Count,NodeList,"); -static bool _set_page_opts = FALSE; - static display_data_t display_data_job[] = { {G_TYPE_INT, SORTID_POS, NULL, FALSE, EDIT_NONE, refresh_job, create_model_job, admin_edit_job}, @@ -2469,11 +2467,6 @@ static List _create_job_info_list(job_info_msg_t *job_info_ptr, for(i=0; i<job_info_ptr->record_count; i++) { job_ptr = &(job_info_ptr->job_array[i]); - if (!working_sview_config.show_hidden) { - /*see if job's part is visible*/ - if (!visible_part(job_ptr->partition)) - continue; - } sview_job_info_ptr = xmalloc(sizeof(sview_job_info_t)); sview_job_info_ptr->job_ptr = job_ptr; sview_job_info_ptr->step_list = list_create(NULL); @@ -2962,12 +2955,12 @@ extern void get_info_job(GtkTable *table, display_data_t *display_data) job_info_t *job_ptr = NULL; ListIterator itr = NULL; GtkTreePath *path = NULL; + static bool set_opts = FALSE; - if (!_set_page_opts) { + if (!set_opts) set_page_opts(JOB_PAGE, display_data_job, SORTID_CNT, _initial_page_opts); - _set_page_opts = TRUE; - } + set_opts = TRUE; /* reset */ if(!table && !display_data) { diff --git a/src/sview/node_info.c b/src/sview/node_info.c index 6a865a40e40..76275c947e9 100644 --- a/src/sview/node_info.c +++ b/src/sview/node_info.c @@ -75,8 +75,6 @@ typedef struct { static char *_initial_page_opts = ",Name,State,CPU Count,Used CPU Count," "Error CPU Count,Cores,Sockets,Threads,Real Memory,Tmp Disk,"; -static bool _set_page_opts = FALSE; - static display_data_t display_data_node[] = { {G_TYPE_INT, SORTID_POS, NULL, FALSE, EDIT_NONE, refresh_node, create_model_node, admin_edit_node}, @@ -635,16 +633,12 @@ extern List create_node_info_list(node_info_msg_t *node_info_ptr, continue; /* constrain list to included partitions' nodes */ - if (by_partition && - apply_partition_check) { - /* there are excluded values to process */ - if (!working_sview_config.show_hidden) { - /* user has not requested to show hidden */ - if (!check_part_includes_node(i)) { - continue; - } - } - } + /* and there are excluded values to process */ + /* and user has not requested to show hidden */ + /* if (by_partition && apply_partition_check */ + /* && !working_sview_config.show_hidden */ + /* && !check_part_includes_node(i)) */ + /* continue; */ sview_node_info_ptr = xmalloc(sizeof(sview_node_info_t)); list_append(info_list, sview_node_info_ptr); @@ -1193,12 +1187,13 @@ extern void get_info_node(GtkTable *table, display_data_t *display_data) sview_node_info_t *sview_node_info_ptr = NULL; ListIterator itr = NULL; GtkTreePath *path = NULL; + static bool set_opts = FALSE; - if (!_set_page_opts) { + if (!set_opts) set_page_opts(NODE_PAGE, display_data_node, SORTID_CNT, _initial_page_opts); - _set_page_opts = TRUE; - } + set_opts = TRUE; + /* reset */ if(!table && !display_data) { if(display_widget) @@ -1258,8 +1253,8 @@ display_it: } if (!path || working_sview_config.grid_topological) { itr = list_iterator_create(info_list); - if (g_topo_info_msg_ptr) { - while ((sview_node_info_ptr = list_next(itr))) { + while ((sview_node_info_ptr = list_next(itr))) { + if (g_topo_info_msg_ptr) { //derive topo_color b_color_ndx = _get_topo_color_ndx(i); @@ -1269,22 +1264,17 @@ display_it: node_state != NODE_STATE_IDLE ) b_color_ndx = i; } - change_grid_color(grid_button_list, i, i, - b_color_ndx, true, 0); - i++; - } - } else { - while ((sview_node_info_ptr = list_next(itr))) { + } else { /* stop blasting out all those button colors */ - if (sview_node_info_ptr->node_ptr->node_state - != NODE_STATE_IDLE) + /* if (sview_node_info_ptr->node_ptr->node_state */ + /* != NODE_STATE_IDLE) */ b_color_ndx = i; - else - b_color_ndx = MAKE_INIT; - change_grid_color(grid_button_list, i, i, - b_color_ndx, true, 0); - i++; + /* else */ + /* b_color_ndx = MAKE_INIT; */ } + change_grid_color(grid_button_list, i, i, + b_color_ndx, true, 0); + i++; } list_iterator_destroy(itr); } else diff --git a/src/sview/part_info.c b/src/sview/part_info.c index 60a329e2a1f..c9c7b8af09f 100644 --- a/src/sview/part_info.c +++ b/src/sview/part_info.c @@ -109,7 +109,6 @@ enum { * on the first startup after a fresh slurm install.*/ static char *_initial_page_opts = ",Partition,Default,Part State," "Time Limit,Node State,NodeList,"; -static bool _set_page_opts = FALSE; static display_data_t display_data_part[] = { {G_TYPE_INT, SORTID_POS, NULL, FALSE, EDIT_NONE, refresh_part}, @@ -1789,20 +1788,6 @@ extern int get_new_info_part(partition_info_msg_t **part_ptr, int force) static time_t last; static bool changed = 0; static uint16_t last_flags = 0; - partition_info_t *m_part_ptr = NULL; -// uid_t *group_uids = NULL; - int i = 0; - struct passwd *pw; - uid_t uid; - - uid = getuid(); - pw = getpwuid (uid); - - /*TODO .. see if slurm has some - * group api I can use to derive - * group perms - */ - char *p=getenv("USER"); if(g_part_info_ptr && !force && ((now - last) < working_sview_config.refresh_delay)) { @@ -1848,19 +1833,6 @@ extern int get_new_info_part(partition_info_msg_t **part_ptr, int force) *part_ptr = new_part_ptr; end_it: - for (i=0; i<g_part_info_ptr->record_count; i++) { - m_part_ptr = &(g_part_info_ptr->partition_array[i]); - if (m_part_ptr->flags & PART_FLAG_HIDDEN) - apply_partition_check = TRUE; - else if (m_part_ptr->allow_groups) { - /* add && strcmp(p,"root")?? */ - if (p && !strstr(m_part_ptr->allow_groups, p)) { - m_part_ptr->flags |= PART_FLAG_HIDDEN; - apply_partition_check = TRUE; - } - } - - } return error_code; } @@ -2093,12 +2065,12 @@ extern void get_info_part(GtkTable *table, display_data_t *display_data) partition_info_t *part_ptr = NULL; ListIterator itr = NULL; GtkTreePath *path = NULL; + static bool set_opts = FALSE; - if (!_set_page_opts) { + if (!set_opts) set_page_opts(PART_PAGE, display_data_part, SORTID_CNT, _initial_page_opts); - _set_page_opts = TRUE; - } + set_opts = TRUE; /* reset */ if(!table && !display_data) { diff --git a/src/sview/resv_info.c b/src/sview/resv_info.c index 3aa96b1dfc4..8c80e443ad5 100644 --- a/src/sview/resv_info.c +++ b/src/sview/resv_info.c @@ -76,8 +76,6 @@ enum { static char *_initial_page_opts = ",Name,Node Count,NodeList," "Time Start,Time End,"; -static bool _set_page_opts = FALSE; - static display_data_t display_data_resv[] = { {G_TYPE_INT, SORTID_POS, NULL, FALSE, EDIT_NONE, refresh_resv, create_model_resv, admin_edit_resv}, @@ -961,12 +959,12 @@ extern void get_info_resv(GtkTable *table, display_data_t *display_data) reserve_info_t *resv_ptr = NULL; time_t now = time(NULL); GtkTreePath *path = NULL; + static bool set_opts = FALSE; - if (!_set_page_opts) { + if (!set_opts) set_page_opts(RESV_PAGE, display_data_resv, SORTID_CNT, _initial_page_opts); - _set_page_opts = TRUE; - } + set_opts = TRUE; /* reset */ if(!table && !display_data) { diff --git a/src/sview/sview.c b/src/sview/sview.c index 88ef17e0e88..0902ee4a558 100644 --- a/src/sview/sview.c +++ b/src/sview/sview.c @@ -383,13 +383,13 @@ static void _set_hidden(GtkToggleAction *action) return; } -static void _set_stabbsets(GtkToggleAction *action) +static void _set_page_opts(GtkToggleAction *action) { char *tmp; if (action) - working_sview_config.save_page_settings + working_sview_config.save_page_opts = gtk_toggle_action_get_active(action); - if (working_sview_config.save_page_settings) + if (working_sview_config.save_page_opts) tmp = g_strdup_printf("Save Page Options now ON"); else tmp = g_strdup_printf("Save Page Options now OFF"); @@ -780,10 +780,10 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) {"hidden", GTK_STOCK_SELECT_COLOR, "Show _Hidden", "<control>h", "Display Hidden Partitions/Jobs", G_CALLBACK(_set_hidden), working_sview_config.show_hidden}, - {"page_opts", GTK_STOCK_SELECT_COLOR, "Save Page _Settings", - "<control>w", "Save Page _Settings", - G_CALLBACK(_set_stabbsets), - working_sview_config.save_page_settings}, + {"page_opts", GTK_STOCK_SELECT_COLOR, "Save Page Options", + "<control>w", "Save Page Options", + G_CALLBACK(_set_page_opts), + working_sview_config.save_page_opts}, #ifdef WANT_TOPO_ON_MAIN_OPTIONS {"topoorder", GTK_STOCK_SELECT_COLOR, "Set Topology Grid", "<control>t", "Set Topology Grid", diff --git a/src/sview/sview.h b/src/sview/sview.h index a68dbf228d4..0c689481d7b 100644 --- a/src/sview/sview.h +++ b/src/sview/sview.h @@ -209,7 +209,7 @@ typedef struct { bool ruled_treeview; bool show_grid; bool show_hidden; - bool save_page_settings; + bool save_page_opts; uint16_t tab_pos; } sview_config_t; -- GitLab