Skip to content
Snippets Groups Projects
Commit b6182313 authored by Moe Jette's avatar Moe Jette
Browse files

Explicitly sort hostlist for each record.

Compare "(null)" and NULL as a match in local _strcmp().
Do not record each partition by default if the partition name will not
be printed.
parent 23ca7832
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,7 @@ static bool _match_part_data(sinfo_data_t *sinfo_ptr, ...@@ -50,6 +50,7 @@ static bool _match_part_data(sinfo_data_t *sinfo_ptr,
partition_info_t* part_ptr); partition_info_t* part_ptr);
static int _query_server(partition_info_msg_t ** part_pptr, static int _query_server(partition_info_msg_t ** part_pptr,
node_info_msg_t ** node_pptr); node_info_msg_t ** node_pptr);
static void _sort_hostlist(List sinfo_list);
static int _strcmp(char *data1, char *data2); static int _strcmp(char *data1, char *data2);
static void _swap_char(char **from, char **to); static void _swap_char(char **from, char **to);
static void _swap_node_rec(node_info_t *from_node, node_info_t *to_node); static void _swap_node_rec(node_info_t *from_node, node_info_t *to_node);
...@@ -160,9 +161,9 @@ static void _filter_nodes(node_info_msg_t *node_msg, int *node_rec_cnt) ...@@ -160,9 +161,9 @@ static void _filter_nodes(node_info_msg_t *node_msg, int *node_rec_cnt)
int i, new_rec_cnt = 0; int i, new_rec_cnt = 0;
hostlist_t hosts = NULL; hostlist_t hosts = NULL;
if ((params.nodes == NULL) && if ((params.nodes == NULL) &&
(params.partition == NULL) && (params.partition == NULL) &&
(params.state_list == NULL)) { (params.state_list == NULL)) {
params.filtering = false; params.filtering = false;
/* Nothing to filter out */ /* Nothing to filter out */
*node_rec_cnt = node_msg->record_count; *node_rec_cnt = node_msg->record_count;
...@@ -255,7 +256,8 @@ static int _build_sinfo_data(List sinfo_list, ...@@ -255,7 +256,8 @@ static int _build_sinfo_data(List sinfo_list,
int j; int j;
/* by default every partition is shown, even if no nodes */ /* by default every partition is shown, even if no nodes */
if ((!params.filtering) && (!params.node_flag)) { if ((!params.filtering) && (!params.node_flag) &&
params.match_flags.partition_flag) {
for (j=0; j<partition_msg->record_count; j++) { for (j=0; j<partition_msg->record_count; j++) {
part_ptr = partition_msg->partition_array + j; part_ptr = partition_msg->partition_array + j;
_create_sinfo(sinfo_list, part_ptr, NULL); _create_sinfo(sinfo_list, part_ptr, NULL);
...@@ -289,9 +291,21 @@ static int _build_sinfo_data(List sinfo_list, ...@@ -289,9 +291,21 @@ static int _build_sinfo_data(List sinfo_list,
list_iterator_destroy(i); list_iterator_destroy(i);
} }
_sort_hostlist(sinfo_list);
return SLURM_SUCCESS; return SLURM_SUCCESS;
} }
static void _sort_hostlist(List sinfo_list)
{
ListIterator i;
sinfo_data_t *sinfo_ptr;
i = list_iterator_create(sinfo_list);
while ((sinfo_ptr = list_next(i)))
hostlist_sort(sinfo_ptr->nodes);
list_iterator_destroy(i);
}
static bool _match_node_data(sinfo_data_t *sinfo_ptr, static bool _match_node_data(sinfo_data_t *sinfo_ptr,
node_info_t *node_ptr) node_info_t *node_ptr)
{ {
...@@ -484,10 +498,12 @@ static void _sinfo_list_delete(void *data) ...@@ -484,10 +498,12 @@ static void _sinfo_list_delete(void *data)
/* like strcmp, but works with NULL pointers */ /* like strcmp, but works with NULL pointers */
static int _strcmp(char *data1, char *data2) static int _strcmp(char *data1, char *data2)
{ {
static char null_str[] = "(null)";
if (data1 == NULL) if (data1 == NULL)
data1 = ""; data1 = null_str;
if (data2 == NULL) if (data2 == NULL)
data2 = ""; data2 = null_str;
return strcmp(data1, data2); return strcmp(data1, data2);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment