From 518ebfb1f9a84151d22ce0d81ba8321fde039b25 Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Tue, 6 Nov 2007 20:29:31 +0000 Subject: [PATCH] svn merge -r12622:12627 https://eris.llnl.gov/svn/slurm/branches/slurm-1.2 --- src/api/job_info.c | 22 ++++-- src/api/partition_info.c | 20 +++-- src/common/node_select.c | 11 ++- src/common/slurm_protocol_api.c | 8 +- src/common/slurm_protocol_api.h | 2 +- .../select/bluegene/plugin/bg_job_place.c | 5 +- src/sacct/print.c | 39 ++++++---- src/sinfo/print.c | 74 +++++++++---------- src/smap/job_functions.c | 6 +- src/smap/partition_functions.c | 7 +- src/squeue/print.c | 70 +++++++++++------- src/sview/block_info.c | 10 ++- src/sview/job_info.c | 47 +++++------- src/sview/node_info.c | 27 ++++--- src/sview/part_info.c | 59 ++++++++------- 15 files changed, 230 insertions(+), 177 deletions(-) diff --git a/src/api/job_info.c b/src/api/job_info.c index 8c1fe6afc9e..ea19c5b38ff 100644 --- a/src/api/job_info.c +++ b/src/api/job_info.c @@ -87,10 +87,11 @@ slurm_print_job_info_msg ( FILE* out, job_info_msg_t *jinfo, int one_liner ) static void _sprint_range(char *str, uint16_t lower, uint16_t upper) { - char tmp[128]; - convert_num_unit((float)lower, str, UNIT_NONE); + /* Note: We don't have the size of str here */ + convert_num_unit((float)lower, str, 16, UNIT_NONE); if (upper > 0) { - convert_num_unit((float)upper, tmp, UNIT_NONE); + char tmp[128]; + convert_num_unit((float)upper, tmp, sizeof(tmp), UNIT_NONE); strcat(str, "-"); strcat(str, tmp); } @@ -255,7 +256,8 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner ) /****** Line 6a (optional) ******/ #if 0 /* mainly for debugging */ - convert_num_unit((float)job_ptr->num_cpu_groups, tmp1, UNIT_NONE); + convert_num_unit((float)job_ptr->num_cpu_groups, tmp1, sizeof(tmp1), + UNIT_NONE); snprintf(tmp_line, sizeof(tmp_line), "NumCPUGroups=%s ", tmp1); @@ -303,9 +305,11 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner ) } /****** Line 7 ******/ - convert_num_unit((float)job_ptr->num_procs, tmp1, UNIT_NONE); + convert_num_unit((float)job_ptr->num_procs, tmp1, sizeof(tmp1), + UNIT_NONE); #ifdef HAVE_BG - convert_num_unit((float)job_ptr->num_nodes, tmp2, UNIT_NONE); + convert_num_unit((float)job_ptr->num_nodes, tmp2, sizeof(tmp2), + UNIT_NONE); sprintf(tmp_line, "ReqProcs=%s MinBPs=%s ", tmp1, tmp2); #else _sprint_range(tmp2, job_ptr->num_nodes, job_ptr->max_nodes); @@ -359,8 +363,10 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner ) xstrcat(out, "\n "); /****** Line 10 ******/ - convert_num_unit((float)job_ptr->job_min_memory, tmp1, UNIT_NONE); - convert_num_unit((float)job_ptr->job_min_tmp_disk, tmp2, UNIT_NONE); + convert_num_unit((float)job_ptr->job_min_memory, tmp1, sizeof(tmp1), + UNIT_NONE); + convert_num_unit((float)job_ptr->job_min_tmp_disk, tmp2, sizeof(tmp2), + UNIT_NONE); snprintf(tmp_line, sizeof(tmp_line), "MinMemory=%s MinTmpDisk=%s Features=%s", tmp1, tmp2, job_ptr->features); diff --git a/src/api/partition_info.c b/src/api/partition_info.c index d75fb87c45b..eed5ae44c2f 100644 --- a/src/api/partition_info.c +++ b/src/api/partition_info.c @@ -105,18 +105,20 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr, int one_liner ) { int j; - char tmp1[7], tmp2[7]; + char tmp1[16], tmp2[16]; char tmp_line[MAXHOSTRANGELEN]; char *out = NULL; uint16_t force, val; /****** Line 1 ******/ #ifdef HAVE_BG - convert_num_unit((float)part_ptr->total_nodes, tmp1, UNIT_NONE); + convert_num_unit((float)part_ptr->total_nodes, tmp1, sizeof(tmp1), + UNIT_NONE); #else - sprintf(tmp1, "%u", part_ptr->total_nodes); + snprintf(tmp1, sizeof(tmp1), "%u", part_ptr->total_nodes); #endif - convert_num_unit((float)part_ptr->total_cpus, tmp2, UNIT_NONE); + convert_num_unit((float)part_ptr->total_cpus, tmp2, sizeof(tmp2), + UNIT_NONE); snprintf(tmp_line, sizeof(tmp_line), "PartitionName=%s TotalNodes=%s TotalCPUs=%s ", part_ptr->name, tmp1, tmp2); @@ -180,9 +182,10 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr, /****** Line 3 ******/ #ifdef HAVE_BG - convert_num_unit((float)part_ptr->min_nodes, tmp1, UNIT_NONE); + convert_num_unit((float)part_ptr->min_nodes, tmp1, sizeof(tmp1), + UNIT_NONE); #else - sprintf(tmp1, "%u", part_ptr->min_nodes); + snprintf(tmp1, sizeof(tmp1), "%u", part_ptr->min_nodes); #endif sprintf(tmp_line, "MinNodes=%s ", tmp1); xstrcat(out, tmp_line); @@ -191,9 +194,10 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr, sprintf(tmp_line, "MaxNodes=UNLIMITED "); else { #ifdef HAVE_BG - convert_num_unit((float)part_ptr->max_nodes, tmp1, UNIT_NONE); + convert_num_unit((float)part_ptr->max_nodes, tmp1, sizeof(tmp1), + UNIT_NONE); #else - sprintf(tmp1, "%u", part_ptr->max_nodes); + snprintf(tmp1, sizeof(tmp1),"%u", part_ptr->max_nodes); #endif sprintf(tmp_line, "MaxNodes=%s ", tmp1); } diff --git a/src/common/node_select.c b/src/common/node_select.c index 3fd10e6c589..97a717bcc05 100644 --- a/src/common/node_select.c +++ b/src/common/node_select.c @@ -1084,7 +1084,7 @@ extern char *select_g_sprint_jobinfo(select_jobinfo_t jobinfo, { uint16_t geometry[SYSTEM_DIMENSIONS]; int i; - char max_procs_char[7], start_char[32]; + char max_procs_char[8], start_char[32]; char *tmp_image = "default"; if (buf == NULL) { @@ -1121,7 +1121,8 @@ extern char *select_g_sprint_jobinfo(select_jobinfo_t jobinfo, sprintf(max_procs_char, "None"); else convert_num_unit((float)jobinfo->max_procs, - max_procs_char, UNIT_NONE); + max_procs_char, sizeof(max_procs_char), + UNIT_NONE); if (jobinfo->start[0] == (uint16_t) NO_VAL) sprintf(start_char, "None"); else { @@ -1143,7 +1144,8 @@ extern char *select_g_sprint_jobinfo(select_jobinfo_t jobinfo, sprintf(max_procs_char, "None"); else convert_num_unit((float)jobinfo->max_procs, - max_procs_char, UNIT_NONE); + max_procs_char, sizeof(max_procs_char), + UNIT_NONE); if (jobinfo->start[0] == (uint16_t) NO_VAL) sprintf(start_char, "None"); else { @@ -1194,7 +1196,8 @@ extern char *select_g_sprint_jobinfo(select_jobinfo_t jobinfo, sprintf(max_procs_char, "None"); else convert_num_unit((float)jobinfo->max_procs, - max_procs_char, UNIT_NONE); + max_procs_char, sizeof(max_procs_char), + UNIT_NONE); snprintf(buf, size, "%s", max_procs_char); break; diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c index c8195ed1b5e..c289b012e4c 100644 --- a/src/common/slurm_protocol_api.c +++ b/src/common/slurm_protocol_api.c @@ -2471,13 +2471,13 @@ extern int nodelist_find(const char *nodelist, const char *name) return id; } -extern void convert_num_unit(float num, char *buf, int orig_type) +extern void convert_num_unit(float num, char *buf, int buf_size, int orig_type) { char *unit = "\0KMGP?"; int i = (int)num % 512; if(i > 0 || (int)num == 0) { - sprintf(buf, "%d%c", (int)num, unit[orig_type]); + snprintf(buf, buf_size, "%d%c", (int)num, unit[orig_type]); return; } @@ -2490,9 +2490,9 @@ extern void convert_num_unit(float num, char *buf, int orig_type) orig_type = UNIT_UNKNOWN; i = (int)num; if(i == num) - sprintf(buf, "%d%c", i, unit[orig_type]); + snprintf(buf, buf_size, "%d%c", i, unit[orig_type]); else - sprintf(buf, "%.2f%c", num, unit[orig_type]); + snprintf(buf, buf_size, "%.2f%c", num, unit[orig_type]); } extern int revert_num_unit(const char *buf) diff --git a/src/common/slurm_protocol_api.h b/src/common/slurm_protocol_api.h index 758fe548aea..990dd9b9822 100644 --- a/src/common/slurm_protocol_api.h +++ b/src/common/slurm_protocol_api.h @@ -788,7 +788,7 @@ extern void slurm_free_msg(slurm_msg_t * msg); /* must free this memory with free not xfree */ extern char *nodelist_nth_host(const char *nodelist, int inx); extern int nodelist_find(const char *nodelist, const char *name); -extern void convert_num_unit(float num, char *buf, int orig_type); +extern void convert_num_unit(float num, char *buf, int buf_size, int orig_type); extern int revert_num_unit(const char *buf); /* diff --git a/src/plugins/select/bluegene/plugin/bg_job_place.c b/src/plugins/select/bluegene/plugin/bg_job_place.c index e043a4e8a38..a7e472b84a7 100644 --- a/src/plugins/select/bluegene/plugin/bg_job_place.c +++ b/src/plugins/select/bluegene/plugin/bg_job_place.c @@ -474,7 +474,8 @@ try_again: /* We use the proccessor count per partition here mostly to see if we can run on a smaller partition. */ - convert_num_unit((float)proc_cnt, tmp_char, UNIT_NONE); + convert_num_unit((float)proc_cnt, tmp_char, + sizeof(tmp_char), UNIT_NONE); debug("block %s CPU count (%s) not suitable", record->bg_block_id, tmp_char); @@ -490,7 +491,7 @@ try_again: || (req_nodes != 0 && record->bp_count > req_nodes) || (record->bp_count < target_size)) { convert_num_unit((float)record->node_cnt, tmp_char, - UNIT_NONE); + sizeof(tmp_char), UNIT_NONE); debug("block %s node count (%s) not suitable", record->bg_block_id, tmp_char); diff --git a/src/sacct/print.c b/src/sacct/print.c index f84cc1b8c24..c4e27f3509d 100644 --- a/src/sacct/print.c +++ b/src/sacct/print.c @@ -277,7 +277,8 @@ void print_idrss(type_t type, void *object) break; } if(rusage.ru_idrss != -1) { - convert_num_unit((float)rusage.ru_idrss, outbuf, UNIT_NONE); + convert_num_unit((float)rusage.ru_idrss, outbuf, + sizeof(outbuf), UNIT_NONE); printf("%8s", outbuf); } } @@ -643,7 +644,8 @@ void print_nnodes(type_t type, void *object) printf("%-8s", "--------"); break; case JOBCOMP: - convert_num_unit((float)jobcomp->node_cnt, temp, UNIT_NONE); + convert_num_unit((float)jobcomp->node_cnt, temp, + sizeof(temp), UNIT_NONE); printf("%-8s", temp); break; default: @@ -887,13 +889,14 @@ void print_pages(type_t type, void *object) sacct = job->sacct; nodes = job->nodes; pos = sacct.min_cpu_id.nodeid; - convert_num_unit((float)sacct.max_pages, buf1, UNIT_NONE); + convert_num_unit((float)sacct.max_pages, + buf1, sizeof(buf1), UNIT_NONE); if(job->track_steps) snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1); else { convert_num_unit((float)sacct.ave_pages, - buf2, UNIT_NONE); + buf2, sizeof(buf2), UNIT_NONE); find_hostname(pos, nodes, buf3); snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", buf1, @@ -907,8 +910,10 @@ void print_pages(type_t type, void *object) sacct = step->sacct; nodes = step->nodes; pos = sacct.min_cpu_id.nodeid; - convert_num_unit((float)sacct.max_pages, buf1, UNIT_NONE); - convert_num_unit((float)sacct.ave_pages, buf2, UNIT_NONE); + convert_num_unit((float)sacct.max_pages, buf1, sizeof(buf1), + UNIT_NONE); + convert_num_unit((float)sacct.ave_pages, buf2, sizeof(buf2), + UNIT_NONE); find_hostname(pos, nodes, buf3); snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", buf1, @@ -946,13 +951,14 @@ void print_rss(type_t type, void *object) sacct = job->sacct; nodes = job->nodes; pos = sacct.min_cpu_id.nodeid; - convert_num_unit((float)sacct.max_rss, buf1, UNIT_NONE); + convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1), + UNIT_NONE); if(job->track_steps) snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1); else { convert_num_unit((float)sacct.ave_rss, - buf2, UNIT_NONE); + buf2, sizeof(buf2), UNIT_NONE); find_hostname(pos, nodes, buf3); snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", buf1, @@ -966,8 +972,10 @@ void print_rss(type_t type, void *object) sacct = step->sacct; nodes = step->nodes; pos = sacct.min_cpu_id.nodeid; - convert_num_unit((float)sacct.max_rss, buf1, UNIT_NONE); - convert_num_unit((float)sacct.ave_rss, buf2, UNIT_NONE); + convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1), + UNIT_NONE); + convert_num_unit((float)sacct.ave_rss, buf2, sizeof(buf2), + UNIT_NONE); find_hostname(pos, nodes, buf3); snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", buf1, @@ -1286,12 +1294,13 @@ void print_vsize(type_t type, void *object) sacct = job->sacct; nodes = job->nodes; pos = sacct.min_cpu_id.nodeid; - convert_num_unit((float)sacct.max_vsize, buf1, UNIT_NONE); + convert_num_unit((float)sacct.max_vsize, + buf1, sizeof(buf1),UNIT_NONE); if(job->track_steps) snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1); else { convert_num_unit((float)sacct.ave_vsize, - buf2, UNIT_NONE); + buf2, sizeof(buf2), UNIT_NONE); find_hostname(pos, nodes, buf3); snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", buf1, @@ -1305,8 +1314,10 @@ void print_vsize(type_t type, void *object) sacct = step->sacct; nodes = step->nodes; pos = sacct.min_cpu_id.nodeid; - convert_num_unit((float)sacct.max_vsize, buf1, UNIT_NONE); - convert_num_unit((float)sacct.ave_vsize, buf2, UNIT_NONE); + convert_num_unit((float)sacct.max_vsize, buf1, sizeof(buf1), + UNIT_NONE); + convert_num_unit((float)sacct.ave_vsize, buf2, sizeof(buf2), + UNIT_NONE); find_hostname(pos, nodes, buf3); snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", buf1, diff --git a/src/sinfo/print.c b/src/sinfo/print.c index 1587dfc68ae..9e8d5a4b958 100644 --- a/src/sinfo/print.c +++ b/src/sinfo/print.c @@ -173,10 +173,10 @@ static int _build_min_max_16_string(char *buffer, int buf_size, uint16_t min, uint16_t max, bool range) { - char tmp_min[7]; - char tmp_max[7]; - convert_num_unit((float)min, tmp_min, UNIT_NONE); - convert_num_unit((float)max, tmp_max, UNIT_NONE); + char tmp_min[8]; + char tmp_max[8]; + convert_num_unit((float)min, tmp_min, sizeof(tmp_min), UNIT_NONE); + convert_num_unit((float)max, tmp_max, sizeof(tmp_max), UNIT_NONE); if (max == min) return snprintf(buffer, buf_size, "%s", tmp_max); @@ -195,10 +195,10 @@ static int _build_min_max_32_string(char *buffer, int buf_size, uint32_t min, uint32_t max, bool range) { - char tmp_min[7]; - char tmp_max[7]; - convert_num_unit((float)min, tmp_min, UNIT_NONE); - convert_num_unit((float)max, tmp_max, UNIT_NONE); + char tmp_min[8]; + char tmp_max[8]; + convert_num_unit((float)min, tmp_min, sizeof(tmp_min), UNIT_NONE); + convert_num_unit((float)max, tmp_max, sizeof(tmp_max), UNIT_NONE); if (max == min) return snprintf(buffer, buf_size, "%s", tmp_max); @@ -307,20 +307,20 @@ int _print_cpus_aiot(sinfo_data_t * sinfo_data, int width, bool right_justify, char *suffix) { char id[FORMAT_STRING_SIZE]; - char tmpa[7]; - char tmpi[7]; - char tmpo[7]; - char tmpt[7]; + char tmpa[8]; + char tmpi[8]; + char tmpo[8]; + char tmpt[8]; if (sinfo_data) { #ifdef HAVE_BG convert_num_unit((float)sinfo_data->cpus_alloc, - tmpa, UNIT_NONE); + tmpa, sizeof(tmpa), UNIT_NONE); convert_num_unit((float)sinfo_data->cpus_idle, - tmpi, UNIT_NONE); + tmpi, sizeof(tmpi), UNIT_NONE); convert_num_unit((float)sinfo_data->cpus_other, - tmpo, UNIT_NONE); + tmpo, sizeof(tmpo), UNIT_NONE); convert_num_unit((float)sinfo_data->cpus_total, - tmpt, UNIT_NONE); + tmpt, sizeof(tmpt), UNIT_NONE); #else sprintf(tmpa, "%u", sinfo_data->cpus_alloc); sprintf(tmpi, "%u", sinfo_data->cpus_idle); @@ -518,13 +518,13 @@ int _print_nodes_t(sinfo_data_t * sinfo_data, int width, bool right_justify, char *suffix) { char id[FORMAT_STRING_SIZE]; - char tmp[7]; + char tmp[8]; if (sinfo_data) { #ifdef HAVE_BG convert_num_unit((float)sinfo_data->nodes_total, tmp, - UNIT_NONE); + sizeof(tmp), UNIT_NONE); #else - sprintf(tmp, "%d", sinfo_data->nodes_total); + snprintf(tmp, sizeof(tmp), "%d", sinfo_data->nodes_total); #endif snprintf(id, FORMAT_STRING_SIZE, "%s", tmp); _print_str(id, width, right_justify, true); @@ -540,17 +540,17 @@ int _print_nodes_ai(sinfo_data_t * sinfo_data, int width, bool right_justify, char *suffix) { char id[FORMAT_STRING_SIZE]; - char tmpa[7]; - char tmpi[7]; + char tmpa[8]; + char tmpi[8]; if (sinfo_data) { #ifdef HAVE_BG convert_num_unit((float)sinfo_data->nodes_alloc, - tmpa, UNIT_NONE); + tmpa, sizeof(tmpa), UNIT_NONE); convert_num_unit((float)sinfo_data->nodes_idle, - tmpi, UNIT_NONE); + tmpi, sizeof(tmpi), UNIT_NONE); #else - sprintf(tmpa, "%d", sinfo_data->nodes_alloc); - sprintf(tmpi, "%d", sinfo_data->nodes_idle); + snprintf(tmpa, sizeof(tmpa), "%d", sinfo_data->nodes_alloc); + snprintf(tmpi, sizeof(tmpi), "%d", sinfo_data->nodes_idle); #endif snprintf(id, FORMAT_STRING_SIZE, "%s/%s", tmpa, tmpi); @@ -567,25 +567,25 @@ int _print_nodes_aiot(sinfo_data_t * sinfo_data, int width, bool right_justify, char *suffix) { char id[FORMAT_STRING_SIZE]; - char tmpa[7]; - char tmpi[7]; - char tmpo[7]; - char tmpt[7]; + char tmpa[8]; + char tmpi[8]; + char tmpo[8]; + char tmpt[8]; if (sinfo_data) { #ifdef HAVE_BG convert_num_unit((float)sinfo_data->nodes_alloc, - tmpa, UNIT_NONE); + tmpa, sizeof(tmpa), UNIT_NONE); convert_num_unit((float)sinfo_data->nodes_idle, - tmpi, UNIT_NONE); + tmpi, sizeof(tmpi), UNIT_NONE); convert_num_unit((float)sinfo_data->nodes_other, - tmpo, UNIT_NONE); + tmpo, sizeof(tmpo), UNIT_NONE); convert_num_unit((float)sinfo_data->nodes_total, - tmpt, UNIT_NONE); + tmpt, sizeof(tmpt), UNIT_NONE); #else - sprintf(tmpa, "%u", sinfo_data->nodes_alloc); - sprintf(tmpi, "%u", sinfo_data->nodes_idle); - sprintf(tmpo, "%u", sinfo_data->nodes_other); - sprintf(tmpt, "%u", sinfo_data->nodes_total); + snprintf(tmpa, sizeof(tmpa), "%u", sinfo_data->nodes_alloc); + snprintf(tmpi, sizeof(tmpi), "%u", sinfo_data->nodes_idle); + snprintf(tmpo, sizeof(tmpo), "%u", sinfo_data->nodes_other); + snprintf(tmpt, sizeof(tmpt), "%u", sinfo_data->nodes_total); #endif snprintf(id, FORMAT_STRING_SIZE, "%s/%s/%s/%s", diff --git a/src/smap/job_functions.c b/src/smap/job_functions.c index 8536e27b773..21eedfc16d9 100644 --- a/src/smap/job_functions.c +++ b/src/smap/job_functions.c @@ -251,7 +251,7 @@ static int _print_text_job(job_info_t * job_ptr) int i = 0; int width = 0; char time_buf[20]; - char tmp_cnt[7]; + char tmp_cnt[8]; uint32_t node_cnt = 0; char *ionodes = NULL; time_t now_time = time(NULL); @@ -271,9 +271,9 @@ static int _print_text_job(job_info_t * job_ptr) if ((node_cnt == 0) || (node_cnt == NO_VAL)) node_cnt = _get_node_cnt(job_ptr); #ifdef HAVE_BG - convert_num_unit((float)node_cnt, tmp_cnt, UNIT_NONE); + convert_num_unit((float)node_cnt, tmp_cnt, sizeof(tmp_cnt), UNIT_NONE); #else - sprintf(tmp_cnt, "%d", node_cnt); + snprintf(tmp_cnt, sizeof(tmp_cnt), "%d", node_cnt); #endif if(!params.commandline) { mvwprintw(text_win, main_ycord, diff --git a/src/smap/partition_functions.c b/src/smap/partition_functions.c index 46a79c9d415..24c37530c11 100644 --- a/src/smap/partition_functions.c +++ b/src/smap/partition_functions.c @@ -517,12 +517,13 @@ static int _print_text_part(partition_info_t *part_ptr, int i = 0; int width = 0; char *nodes = NULL, time_buf[20]; - char tmp_cnt[7]; + char tmp_cnt[8]; #ifdef HAVE_BG - convert_num_unit((float)part_ptr->total_nodes, tmp_cnt, UNIT_NONE); + convert_num_unit((float)part_ptr->total_nodes, tmp_cnt, + sizeof(tmp_cnt), UNIT_NONE); #else - sprintf(tmp_cnt, "%u", part_ptr->total_nodes); + snprintf(tmp_cnt, sizeof(tmp_cnt), "%u", part_ptr->total_nodes); #endif if(!params.commandline) { diff --git a/src/squeue/print.c b/src/squeue/print.c index 19092ab662e..d15d0424dd5 100644 --- a/src/squeue/print.c +++ b/src/squeue/print.c @@ -543,7 +543,7 @@ int _print_job_reason_list(job_info_t * job, int width, bool right, char* suffix) { char *ionodes = NULL; - char tmp_char[6]; + char tmp_char[16]; if (job == NULL) { /* Print the Header instead */ #ifdef HAVE_BG @@ -567,7 +567,8 @@ int _print_job_reason_list(job_info_t * job, int width, bool right, _print_nodes(job->nodes, width, right, false); if(ionodes) { - sprintf(tmp_char, "[%s]", ionodes); + snprintf(tmp_char, sizeof(tmp_char), "[%s]", + ionodes); _print_str(tmp_char, width, right, false); } } @@ -600,7 +601,7 @@ int _print_job_node_inx(job_info_t * job, int width, bool right, char* suffix) int _print_job_num_procs(job_info_t * job, int width, bool right, char* suffix) { - char tmp_char[6]; + char tmp_char[8]; if (job == NULL) /* Print the Header instead */ _print_str("CPUS", width, right, true); else { @@ -610,9 +611,11 @@ int _print_job_num_procs(job_info_t * job, int width, bool right, char* suffix) cnt += job->cpus_per_node[i] * job->cpu_count_reps[i]; } - convert_num_unit((float)cnt, tmp_char, UNIT_NONE); + convert_num_unit((float)cnt, tmp_char, + sizeof(tmp_char), UNIT_NONE); } else { - convert_num_unit((float)job->num_procs, tmp_char, UNIT_NONE); + convert_num_unit((float)job->num_procs, tmp_char, + sizeof(tmp_char), UNIT_NONE); } _print_str(tmp_char, width, right, true); } @@ -625,7 +628,7 @@ int _print_job_num_nodes(job_info_t * job, int width, bool right_justify, char* suffix) { uint32_t node_cnt = 0; - char tmp_char[6]; + char tmp_char[8]; if (job == NULL) /* Print the Header instead */ _print_str("NODES", width, right_justify, true); @@ -639,9 +642,10 @@ int _print_job_num_nodes(job_info_t * job, int width, bool right_justify, node_cnt = _get_node_cnt(job); #ifdef HAVE_BG - convert_num_unit((float)node_cnt, tmp_char, UNIT_NONE); + convert_num_unit((float)node_cnt, tmp_char, sizeof(tmp_char), + UNIT_NONE); #else - sprintf(tmp_char, "%d", node_cnt); + snprintf(tmp_char, sizeof(tmp_char), "%d", node_cnt); #endif _print_str(tmp_char, width, right_justify, true); } @@ -675,9 +679,12 @@ int _print_job_num_sct(job_info_t * job, int width, bool right_justify, char threads[10]; char sct[(10+1)*3]; if (job) { - convert_num_unit((float)job->min_sockets, sockets, UNIT_NONE); - convert_num_unit((float)job->min_cores, cores, UNIT_NONE); - convert_num_unit((float)job->min_threads, threads, UNIT_NONE); + convert_num_unit((float)job->min_sockets, sockets, + sizeof(sockets), UNIT_NONE); + convert_num_unit((float)job->min_cores, cores, + sizeof(cores), UNIT_NONE); + convert_num_unit((float)job->min_threads, threads, + sizeof(threads), UNIT_NONE); sct[0] = '\0'; strcat(sct, sockets); strcat(sct, ":"); @@ -701,7 +708,8 @@ int _print_job_num_sockets(job_info_t * job, int width, bool right_justify, if (job == NULL) /* Print the Header instead */ _print_str("SOCKETS", width, right_justify, true); else { - convert_num_unit((float)job->min_sockets, tmp_char, UNIT_NONE); + convert_num_unit((float)job->min_sockets, tmp_char, + sizeof(tmp_char), UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } if (suffix) @@ -716,7 +724,8 @@ int _print_job_num_cores(job_info_t * job, int width, bool right_justify, if (job == NULL) /* Print the Header instead */ _print_str("CORES", width, right_justify, true); else { - convert_num_unit((float)job->min_cores, tmp_char, UNIT_NONE); + convert_num_unit((float)job->min_cores, tmp_char, + sizeof(tmp_char), UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } if (suffix) @@ -731,7 +740,8 @@ int _print_job_num_threads(job_info_t * job, int width, bool right_justify, if (job == NULL) /* Print the Header instead */ _print_str("THREADS", width, right_justify, true); else { - convert_num_unit((float)job->min_threads, tmp_char, UNIT_NONE); + convert_num_unit((float)job->min_threads, tmp_char, + sizeof(tmp_char), UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } if (suffix) @@ -789,12 +799,13 @@ int _print_job_contiguous(job_info_t * job, int width, bool right_justify, int _print_job_min_procs(job_info_t * job, int width, bool right_justify, char* suffix) { - char tmp_char[6]; + char tmp_char[8]; if (job == NULL) /* Print the Header instead */ _print_str("MIN_PROCS", width, right_justify, true); else { - convert_num_unit((float)job->job_min_procs, tmp_char, UNIT_NONE); + convert_num_unit((float)job->job_min_procs, tmp_char, + sizeof(tmp_char), UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } if (suffix) @@ -805,12 +816,13 @@ int _print_job_min_procs(job_info_t * job, int width, bool right_justify, int _print_job_min_sockets(job_info_t * job, int width, bool right_justify, char* suffix) { - char tmp_char[6]; + char tmp_char[8]; if (job == NULL) /* Print the Header instead */ _print_str("MIN_SOCKETS", width, right_justify, true); else { - convert_num_unit((float)job->job_min_sockets, tmp_char, UNIT_NONE); + convert_num_unit((float)job->job_min_sockets, tmp_char, + sizeof(tmp_char), UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } if (suffix) @@ -821,12 +833,13 @@ int _print_job_min_sockets(job_info_t * job, int width, bool right_justify, int _print_job_min_cores(job_info_t * job, int width, bool right_justify, char* suffix) { - char tmp_char[6]; + char tmp_char[8]; if (job == NULL) /* Print the Header instead */ _print_str("MIN_CORES", width, right_justify, true); else { - convert_num_unit((float)job->job_min_cores, tmp_char, UNIT_NONE); + convert_num_unit((float)job->job_min_cores, tmp_char, + sizeof(tmp_char), UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } if (suffix) @@ -837,12 +850,13 @@ int _print_job_min_cores(job_info_t * job, int width, bool right_justify, int _print_job_min_threads(job_info_t * job, int width, bool right_justify, char* suffix) { - char tmp_char[6]; + char tmp_char[8]; if (job == NULL) /* Print the Header instead */ _print_str("MIN_THREADS", width, right_justify, true); else { - convert_num_unit((float)job->job_min_threads, tmp_char, UNIT_NONE); + convert_num_unit((float)job->job_min_threads, tmp_char, + sizeof(tmp_char), UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } if (suffix) @@ -862,11 +876,13 @@ int _print_job_min_memory(job_info_t * job, int width, bool right_justify, else { tmp_char[0] = '\0'; if (job->job_max_memory < job->job_min_memory) { - convert_num_unit((float)job->job_max_memory, max_mem, UNIT_NONE); + convert_num_unit((float)job->job_max_memory, max_mem, + sizeof(max_mem), UNIT_NONE); strcat(tmp_char, max_mem); strcat(tmp_char, "-"); - } - convert_num_unit((float)job->job_min_memory, min_mem, UNIT_NONE); + } + convert_num_unit((float)job->job_min_memory, min_mem, + sizeof(min_mem), UNIT_NONE); strcat(tmp_char, min_mem); _print_str(tmp_char, width, right_justify, true); } @@ -880,13 +896,13 @@ int _print_job_min_tmp_disk(job_info_t * job, int width, bool right_justify, char* suffix) { - char tmp_char[6]; + char tmp_char[10]; if (job == NULL) /* Print the Header instead */ _print_str("MIN_TMP_DISK", width, right_justify, true); else { convert_num_unit((float)job->job_min_tmp_disk, - tmp_char, UNIT_NONE); + tmp_char, sizeof(tmp_char), UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } diff --git a/src/sview/block_info.c b/src/sview/block_info.c index 6e4251b6cab..ee1afa88e40 100644 --- a/src/sview/block_info.c +++ b/src/sview/block_info.c @@ -207,7 +207,7 @@ static void _layout_block_record(GtkTreeView *treeview, sview_block_info_t *block_ptr, int update) { - char tmp_cnt[7]; + char tmp_cnt[8]; GtkTreeIter iter; GtkTreeStore *treestore = GTK_TREE_STORE(gtk_tree_view_get_model(treeview)); @@ -238,7 +238,8 @@ static void _layout_block_record(GtkTreeView *treeview, SORTID_USE), _convert_node_use(block_ptr->bg_node_use)); - convert_num_unit((float)block_ptr->node_cnt, tmp_cnt, UNIT_NONE); + convert_num_unit((float)block_ptr->node_cnt, tmp_cnt, sizeof(tmp_cnt), + UNIT_NONE); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_block, SORTID_NODES), @@ -269,7 +270,7 @@ static void _layout_block_record(GtkTreeView *treeview, static void _update_block_record(sview_block_info_t *block_ptr, GtkTreeStore *treestore, GtkTreeIter *iter) { - char tmp_cnt[7]; + char tmp_cnt[8]; gtk_tree_store_set(treestore, iter, SORTID_BLOCK, block_ptr->bg_block_name, -1); @@ -284,7 +285,8 @@ static void _update_block_record(sview_block_info_t *block_ptr, gtk_tree_store_set(treestore, iter, SORTID_USE, _convert_node_use(block_ptr->bg_node_use), -1); - convert_num_unit((float)block_ptr->node_cnt, tmp_cnt, UNIT_NONE); + convert_num_unit((float)block_ptr->node_cnt, tmp_cnt, sizeof(tmp_cnt), + UNIT_NONE); gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_cnt, -1); gtk_tree_store_set(treestore, iter, SORTID_NODELIST, diff --git a/src/sview/job_info.c b/src/sview/job_info.c index 195f7e4b751..e92bfd1888e 100644 --- a/src/sview/job_info.c +++ b/src/sview/job_info.c @@ -1188,9 +1188,10 @@ static void _layout_job_record(GtkTreeView *treeview, #ifdef HAVE_BG convert_num_unit((float)sview_job_info_ptr->node_cnt, - tmp_char, UNIT_NONE); + tmp_char, sizeof(tmp_char), UNIT_NONE); #else - sprintf(tmp_char, "%u", sview_job_info_ptr->node_cnt); + snprintf(tmp_char, sizeof(tmp_char), "%u", + sview_job_info_ptr->node_cnt); #endif add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_job, @@ -1198,9 +1199,10 @@ static void _layout_job_record(GtkTreeView *treeview, tmp_char); #ifdef HAVE_BG - convert_num_unit((float)job_ptr->num_procs, tmp_char, UNIT_NONE); + convert_num_unit((float)job_ptr->num_procs, tmp_char, sizeof(tmp_char), + UNIT_NONE); #else - sprintf(tmp_char, "%u", job_ptr->num_procs); + snprintf(tmp_char, sizeof(tmp_char), "%u", job_ptr->num_procs); #endif add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_job, @@ -1592,7 +1594,7 @@ static void _update_job_record(sview_job_info_t *sview_job_info_ptr, #ifdef HAVE_BG convert_num_unit((float)sview_job_info_ptr->node_cnt, - tmp_char, UNIT_NONE); + tmp_char, sizeof(tmp_char), UNIT_NONE); #else sprintf(tmp_char, "%u", sview_job_info_ptr->node_cnt); #endif @@ -1600,9 +1602,10 @@ static void _update_job_record(sview_job_info_t *sview_job_info_ptr, SORTID_NODES, tmp_char, -1); #ifdef HAVE_BG - convert_num_unit((float)job_ptr->num_procs, tmp_char, UNIT_NONE); + convert_num_unit((float)job_ptr->num_procs, tmp_char, sizeof(tmp_char), + UNIT_NONE); #else - sprintf(tmp_char, "%u", job_ptr->num_procs); + snprintf(tmp_char, sizeof(tmp_char), "%u", job_ptr->num_procs); #endif gtk_tree_store_set(treestore, iter, SORTID_NUM_PROCS, tmp_char, -1); @@ -1643,57 +1646,43 @@ static void _update_job_record(sview_job_info_t *sview_job_info_ptr, SORTID_MAX_NODES, tmp_char, -1); } if(job_ptr->cpus_per_task > 0) { - //convert_num_unit((float)job_ptr->cpus_per_task, - // tmp_char, UNIT_NONE); sprintf(tmp_char, "%u", job_ptr->cpus_per_task); gtk_tree_store_set(treestore, iter, SORTID_CPUS_PER_TASK, tmp_char, -1); } - //convert_num_unit((float)job_ptr->job_min_procs, tmp_char, UNIT_NONE); sprintf(tmp_char, "%u", job_ptr->job_min_procs); gtk_tree_store_set(treestore, iter, SORTID_REQ_PROCS, tmp_char, -1); - //convert_num_unit((float)job_ptr->min_sockets, tmp_char, UNIT_NONE); sprintf(tmp_char, "%u", job_ptr->min_sockets); gtk_tree_store_set(treestore, iter, SORTID_MIN_SOCKETS, tmp_char, -1); - //convert_num_unit((float)job_ptr->max_sockets, tmp_char, UNIT_NONE); sprintf(tmp_char, "%u", job_ptr->max_sockets); gtk_tree_store_set(treestore, iter, SORTID_MAX_SOCKETS, tmp_char, -1); - //convert_num_unit((float)job_ptr->min_cores, tmp_char, UNIT_NONE); sprintf(tmp_char, "%u", job_ptr->min_cores); gtk_tree_store_set(treestore, iter, SORTID_MIN_CORES, tmp_char, -1); - //convert_num_unit((float)job_ptr->max_cores, tmp_char, UNIT_NONE); sprintf(tmp_char, "%u", job_ptr->max_cores); gtk_tree_store_set(treestore, iter, SORTID_MAX_CORES, tmp_char, -1); - //convert_num_unit((float)job_ptr->min_threads, tmp_char, UNIT_NONE); sprintf(tmp_char, "%u", job_ptr->min_threads); gtk_tree_store_set(treestore, iter, SORTID_MIN_THREADS, tmp_char, -1); - //convert_num_unit((float)job_ptr->max_threads, tmp_char, UNIT_NONE); sprintf(tmp_char, "%u", job_ptr->max_threads); gtk_tree_store_set(treestore, iter, SORTID_MAX_THREADS, tmp_char, -1); - //convert_num_unit((float)job_ptr->job_min_memory, - // tmp_char, UNIT_NONE); sprintf(tmp_char, "%u", job_ptr->job_min_memory); gtk_tree_store_set(treestore, iter, SORTID_MIN_MEM, tmp_char, -1); - //convert_num_unit((float)job_ptr->job_max_memory, - // tmp_char, UNIT_NONE); + sprintf(tmp_char, "%u", job_ptr->job_max_memory); gtk_tree_store_set(treestore, iter, SORTID_MAX_MEM, tmp_char, -1); - //convert_num_unit((float)job_ptr->job_min_tmp_disk, - // tmp_char, UNIT_NONE); sprintf(tmp_char, "%u", job_ptr->job_min_tmp_disk); gtk_tree_store_set(treestore, iter, SORTID_TMP_DISK, tmp_char, -1); @@ -1767,10 +1756,10 @@ static void _layout_step_record(GtkTreeView *treeview, nodes = step_ptr->nodes; #ifdef HAVE_BG convert_num_unit((float)step_ptr->num_tasks, - tmp_char, UNIT_NONE); + tmp_char, sizeof(tmp_char), UNIT_NONE); #else convert_num_unit((float)_nodes_in_list(nodes), - tmp_char, UNIT_NONE); + tmp_char, sizeof(tmp_char), UNIT_NONE); #endif add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_job, @@ -1818,7 +1807,8 @@ static void _layout_step_record(GtkTreeView *treeview, SORTID_NAME), step_ptr->name); - convert_num_unit((float)step_ptr->num_tasks, tmp_char, UNIT_NONE); + convert_num_unit((float)step_ptr->num_tasks, tmp_char, sizeof(tmp_char), + UNIT_NONE); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_job, SORTID_TASKS), @@ -1857,10 +1847,10 @@ static void _update_step_record(job_step_info_t *step_ptr, nodes = step_ptr->nodes; #ifdef HAVE_BG convert_num_unit((float)step_ptr->num_tasks, - tmp_char, UNIT_NONE); + tmp_char, sizeof(tmp_char), UNIT_NONE); #else convert_num_unit((float)_nodes_in_list(nodes), - tmp_char, UNIT_NONE); + tmp_char, sizeof(tmp_char), UNIT_NONE); #endif gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_char, -1); @@ -1894,7 +1884,8 @@ static void _update_step_record(job_step_info_t *step_ptr, gtk_tree_store_set(treestore, iter, SORTID_NAME, step_ptr->name, -1); - convert_num_unit((float)step_ptr->num_tasks, tmp_char, UNIT_NONE); + convert_num_unit((float)step_ptr->num_tasks, tmp_char, sizeof(tmp_char), + UNIT_NONE); gtk_tree_store_set(treestore, iter, SORTID_TASKS, tmp_char, -1); diff --git a/src/sview/node_info.c b/src/sview/node_info.c index 6348522e573..2330f0f8f71 100644 --- a/src/sview/node_info.c +++ b/src/sview/node_info.c @@ -137,43 +137,50 @@ static void _layout_node_record(GtkTreeView *treeview, lower); xfree(lower); - convert_num_unit((float)node_ptr->cpus, tmp_cnt, UNIT_NONE); + convert_num_unit((float)node_ptr->cpus, tmp_cnt, sizeof(tmp_cnt), + UNIT_NONE); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_node, SORTID_CPUS), tmp_cnt); - convert_num_unit((float)node_ptr->used_cpus, tmp_cnt, UNIT_NONE); + convert_num_unit((float)node_ptr->used_cpus, tmp_cnt, sizeof(tmp_cnt), + UNIT_NONE); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_node, SORTID_USED_CPUS), tmp_cnt); - convert_num_unit((float)node_ptr->cores, tmp_cnt, UNIT_NONE); + convert_num_unit((float)node_ptr->cores, tmp_cnt, sizeof(tmp_cnt), + UNIT_NONE); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_node, SORTID_CORES), tmp_cnt); - convert_num_unit((float)node_ptr->sockets, tmp_cnt, UNIT_NONE); + convert_num_unit((float)node_ptr->sockets, tmp_cnt, sizeof(tmp_cnt), + UNIT_NONE); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_node, SORTID_SOCKETS), tmp_cnt); - convert_num_unit((float)node_ptr->threads, tmp_cnt, UNIT_NONE); + convert_num_unit((float)node_ptr->threads, tmp_cnt, sizeof(tmp_cnt), + UNIT_NONE); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_node, SORTID_THREADS), tmp_cnt); - convert_num_unit((float)node_ptr->real_memory, tmp_cnt, UNIT_MEGA); + convert_num_unit((float)node_ptr->real_memory, tmp_cnt, sizeof(tmp_cnt), + UNIT_MEGA); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_node, SORTID_MEMORY), tmp_cnt); - convert_num_unit((float)node_ptr->tmp_disk, tmp_cnt, UNIT_MEGA); + convert_num_unit((float)node_ptr->tmp_disk, tmp_cnt, sizeof(tmp_cnt), + UNIT_MEGA); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_node, SORTID_DISK), @@ -217,9 +224,11 @@ static void _update_node_record(node_info_t *node_ptr, node_ptr->sockets, -1); gtk_tree_store_set(treestore, iter, SORTID_THREADS, node_ptr->threads, -1); - convert_num_unit((float)node_ptr->real_memory, tmp_cnt, UNIT_MEGA); + convert_num_unit((float)node_ptr->real_memory, tmp_cnt, sizeof(tmp_cnt), + UNIT_MEGA); gtk_tree_store_set(treestore, iter, SORTID_MEMORY, tmp_cnt, -1); - convert_num_unit((float)node_ptr->tmp_disk, tmp_cnt, UNIT_MEGA); + convert_num_unit((float)node_ptr->tmp_disk, tmp_cnt, sizeof(tmp_cnt), + UNIT_MEGA); gtk_tree_store_set(treestore, iter, SORTID_DISK, tmp_cnt, -1); gtk_tree_store_set(treestore, iter, SORTID_WEIGHT, node_ptr->weight, -1); diff --git a/src/sview/part_info.c b/src/sview/part_info.c index 425262798ae..6a62205864b 100644 --- a/src/sview/part_info.c +++ b/src/sview/part_info.c @@ -258,11 +258,13 @@ static int _build_min_max_16_string(char *buffer, int buf_size, uint16_t min, uint16_t max, bool range) { - char tmp_min[7]; - char tmp_max[7]; - convert_num_unit((float)min, tmp_min, UNIT_NONE); - if(max != (uint16_t) INFINITE) - convert_num_unit((float)max, tmp_max, UNIT_NONE); + char tmp_min[8]; + char tmp_max[8]; + convert_num_unit((float)min, tmp_min, sizeof(tmp_min), UNIT_NONE); + if(max != (uint16_t) INFINITE) { + convert_num_unit((float)max, tmp_max, sizeof(tmp_max), + UNIT_NONE); + } if (max == min) return snprintf(buffer, buf_size, "%s", tmp_max); @@ -281,10 +283,10 @@ static int _build_min_max_32_string(char *buffer, int buf_size, uint32_t min, uint32_t max, bool range) { - char tmp_min[7]; - char tmp_max[7]; - convert_num_unit((float)min, tmp_min, UNIT_NONE); - convert_num_unit((float)max, tmp_max, UNIT_NONE); + char tmp_min[8]; + char tmp_max[8]; + convert_num_unit((float)min, tmp_min, sizeof(tmp_min), UNIT_NONE); + convert_num_unit((float)max, tmp_max, sizeof(tmp_max), UNIT_NONE); if (max == min) return snprintf(buffer, buf_size, "%s", tmp_max); @@ -725,9 +727,9 @@ static void _layout_part_record(GtkTreeView *treeview, GtkTreeIter iter; ListIterator itr = NULL; char time_buf[20], tmp_buf[20]; - char tmp_cnt[7]; - char tmp_cnt1[7]; - char tmp_cnt2[7]; + char tmp_cnt[8]; + char tmp_cnt1[8]; + char tmp_cnt2[8]; partition_info_t *part_ptr = sview_part_info->part_ptr; sview_part_sub_t *sview_part_sub = NULL; sview_part_sub_t *temp_part_sub = NULL; @@ -801,7 +803,7 @@ static void _layout_part_record(GtkTreeView *treeview, snprintf(time_buf, sizeof(time_buf), "infinite"); else { convert_num_unit((float)part_ptr->min_nodes, - time_buf, UNIT_NONE); + time_buf, sizeof(time_buf), UNIT_NONE); } add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_part, @@ -811,7 +813,7 @@ static void _layout_part_record(GtkTreeView *treeview, snprintf(time_buf, sizeof(time_buf), "infinite"); else { convert_num_unit((float)part_ptr->max_nodes, - time_buf, UNIT_NONE); + time_buf, sizeof(time_buf), UNIT_NONE); } add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_part, @@ -854,7 +856,8 @@ static void _layout_part_record(GtkTreeView *treeview, temp_char); #ifdef HAVE_BG - convert_num_unit((float)part_ptr->total_nodes, tmp_cnt, UNIT_NONE); + convert_num_unit((float)part_ptr->total_nodes, tmp_cnt, + sizeof(tmp_buf), UNIT_NONE); #else sprintf(tmp_cnt, "%u", part_ptr->total_nodes); #endif @@ -862,7 +865,8 @@ static void _layout_part_record(GtkTreeView *treeview, find_col_name(display_data_part, SORTID_NODES), tmp_cnt); - convert_num_unit((float)part_ptr->total_cpus, tmp_cnt, UNIT_NONE); + convert_num_unit((float)part_ptr->total_cpus, tmp_cnt, sizeof(tmp_cnt), + UNIT_NONE); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_part, SORTID_CPUS), @@ -901,9 +905,12 @@ static void _layout_part_record(GtkTreeView *treeview, other_part_sub.reason = temp_part_sub->reason; } } - convert_num_unit((float)alloc_part_sub.node_cnt, tmp_cnt, UNIT_NONE); - convert_num_unit((float)idle_part_sub.node_cnt, tmp_cnt1, UNIT_NONE); - convert_num_unit((float)other_part_sub.node_cnt, tmp_cnt2, UNIT_NONE); + convert_num_unit((float)alloc_part_sub.node_cnt, + tmp_cnt, sizeof(tmp_cnt), UNIT_NONE); + convert_num_unit((float)idle_part_sub.node_cnt, + tmp_cnt1, sizeof(tmp_cnt1), UNIT_NONE); + convert_num_unit((float)other_part_sub.node_cnt, + tmp_cnt2, sizeof(tmp_cnt2), UNIT_NONE); snprintf(tmp, sizeof(tmp), "%s/%s/%s", tmp_cnt, tmp_cnt1, tmp_cnt2); add_display_treestore_line(update, treestore, &iter, @@ -925,7 +932,7 @@ static void _update_part_record(sview_part_info_t *sview_part_info, GtkTreeIter *iter) { char time_buf[20], tmp_buf[20]; - char tmp_cnt[7]; + char tmp_cnt[8]; char *temp_char = NULL; partition_info_t *part_ptr = sview_part_info->part_ptr; GtkTreeIter sub_iter; @@ -969,7 +976,7 @@ static void _update_part_record(sview_part_info_t *sview_part_info, snprintf(time_buf, sizeof(time_buf), "infinite"); else { convert_num_unit((float)part_ptr->min_nodes, - time_buf, UNIT_NONE); + time_buf, sizeof(time_buf), UNIT_NONE); } gtk_tree_store_set(treestore, iter, SORTID_MIN_NODES, time_buf, -1); @@ -977,7 +984,7 @@ static void _update_part_record(sview_part_info_t *sview_part_info, snprintf(time_buf, sizeof(time_buf), "infinite"); else { convert_num_unit((float)part_ptr->max_nodes, - time_buf, UNIT_NONE); + time_buf, sizeof(time_buf), UNIT_NONE); } gtk_tree_store_set(treestore, iter, SORTID_MAX_NODES, time_buf, -1); @@ -1009,7 +1016,8 @@ static void _update_part_record(sview_part_info_t *sview_part_info, gtk_tree_store_set(treestore, iter, SORTID_GROUPS, temp_char, -1); #ifdef HAVE_BG - convert_num_unit((float)part_ptr->total_nodes, tmp_cnt, UNIT_NONE); + convert_num_unit((float)part_ptr->total_nodes, tmp_cnt, + sizeof(tmp_cnt), UNIT_NONE); #else sprintf(tmp_cnt, "%u", part_ptr->total_nodes); #endif @@ -1047,7 +1055,7 @@ static void _update_part_sub_record(sview_part_sub_t *sview_part_sub, GtkTreeStore *treestore, GtkTreeIter *iter) { char time_buf[20]; - char tmp_cnt[7]; + char tmp_cnt[8]; partition_info_t *part_ptr = sview_part_sub->part_ptr; char *upper = NULL, *lower = NULL; char tmp[MAXHOSTRANGELEN]; @@ -1083,7 +1091,8 @@ static void _update_part_sub_record(sview_part_sub_t *sview_part_sub, sview_part_sub->max_weight, false); gtk_tree_store_set(treestore, iter, SORTID_WEIGHT, time_buf, -1); - convert_num_unit((float)sview_part_sub->node_cnt, tmp_cnt, UNIT_NONE); + convert_num_unit((float)sview_part_sub->node_cnt, tmp_cnt, + sizeof(tmp_cnt), UNIT_NONE); gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_cnt, -1); hostlist_ranged_string(sview_part_sub->hl, sizeof(tmp), tmp); -- GitLab