From 646545792ddf3c0447dfb26bd18dbd031dafe461 Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Wed, 28 Aug 2013 09:07:58 -0700 Subject: [PATCH] Various minor possible bug fixes as reported by clang tool --- src/plugins/mpi/pmi2/pmi1.c | 10 ++++++---- src/plugins/select/linear/select_linear.c | 10 +++++++--- src/sacctmgr/qos_functions.c | 2 ++ src/slurmd/slurmstepd/io.c | 8 ++++---- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/plugins/mpi/pmi2/pmi1.c b/src/plugins/mpi/pmi2/pmi1.c index e5a5d67511b..721903f45d1 100644 --- a/src/plugins/mpi/pmi2/pmi1.c +++ b/src/plugins/mpi/pmi2/pmi1.c @@ -119,7 +119,7 @@ _handle_get_maxes(int fd, int lrank, client_req_t *req) KVSNAMEMAX_KEY"=%d " KEYLENMAX_KEY"=%d " VALLENMAX_KEY"=%d\n", rc, MAXKVSNAME, MAXKEYLEN, MAXVALLEN); - rc = client_resp_send(resp, fd); + (void) client_resp_send(resp, fd); client_resp_free(resp); debug3("mpi/pmi2: out _handle_get_maxes"); @@ -138,7 +138,7 @@ _handle_get_universe_size(int fd, int lrank, client_req_t *req) client_resp_append(resp, CMD_KEY"="UNIVSIZE_CMD" " RC_KEY"=%d " SIZE_KEY"=%d\n", rc, job_info.ntasks); - rc = client_resp_send(resp, fd); + (void) client_resp_send(resp, fd); client_resp_free(resp); debug3("mpi/pmi2: out _handle_get_universe_size"); @@ -162,7 +162,7 @@ _handle_get_appnum(int fd, int lrank, client_req_t *req) */ client_resp_append(resp, CMD_KEY"="APPNUM_CMD" " RC_KEY"=%d " APPNUM_KEY"=-1\n", rc); - rc = client_resp_send(resp, fd); + (void) client_resp_send(resp, fd); client_resp_free(resp); debug3("mpi/pmi2: out _handle_get_appnum"); @@ -582,8 +582,10 @@ _handle_pmi1_mcmd_buf(int fd, int lrank, int buf_size, int buf_len, char **pbuf) tmp_ptr = NULL; while (tmp_buf[0] != '\0') { tmp_ptr = strstr(tmp_buf, ENDCMD_KEY"\n"); - if ( tmp_ptr == NULL) { + if (tmp_ptr == NULL) { error("mpi/pmi2: this is impossible"); + rc = SLURM_ERROR; + break; } *tmp_ptr = '\0'; n = tmp_ptr - tmp_buf; diff --git a/src/plugins/select/linear/select_linear.c b/src/plugins/select/linear/select_linear.c index b1622af730e..2e4cc34c9f0 100644 --- a/src/plugins/select/linear/select_linear.c +++ b/src/plugins/select/linear/select_linear.c @@ -1817,9 +1817,10 @@ static int _decr_node_job_cnt(int node_inx, struct job_record *job_ptr, { struct node_record *node_ptr = node_record_table_ptr + node_inx; struct part_cr_record *part_cr_ptr; - bool exclusive, is_job_running; + bool exclusive = false, is_job_running; - exclusive = (job_ptr->details->shared == 0); + if (job_ptr->details) + exclusive = (job_ptr->details->shared == 0); if (exclusive) { if (cr_ptr->nodes[node_inx].exclusive_cnt) cr_ptr->nodes[node_inx].exclusive_cnt--; @@ -2261,7 +2262,10 @@ static void _init_node_cr(void) if (job_resrcs_ptr->node_bitmap == NULL) continue; - exclusive = (job_ptr->details->shared == 0); + if (job_ptr->details) + exclusive = (job_ptr->details->shared == 0); + else + exclusive = 0; node_offset = -1; i_first = bit_ffs(job_resrcs_ptr->node_bitmap); i_last = bit_fls(job_resrcs_ptr->node_bitmap); diff --git a/src/sacctmgr/qos_functions.c b/src/sacctmgr/qos_functions.c index 2a381336d1c..16f97e9f781 100644 --- a/src/sacctmgr/qos_functions.c +++ b/src/sacctmgr/qos_functions.c @@ -257,6 +257,8 @@ static int _set_rec(int *start, int argc, char *argv[], slurm_addto_char_list(name_list, argv[i]+end); } else if (!strncasecmp (argv[i], "Description", MAX(command_len, 1))) { + if (!qos) + continue; if (!qos->description) qos->description = strip_quotes(argv[i]+end, NULL, 1); diff --git a/src/slurmd/slurmstepd/io.c b/src/slurmd/slurmstepd/io.c index c963c07ed3b..668623dfe93 100644 --- a/src/slurmd/slurmstepd/io.c +++ b/src/slurmd/slurmstepd/io.c @@ -555,7 +555,7 @@ _local_file_write(eio_obj_t *obj, List objs) if (!header_tmp_buf) fatal("Failure to allocate memory for a message header"); io_hdr_unpack(&header, header_tmp_buf); - header_tmp_buf->head = NULL; + header_tmp_buf->head = NULL; /* CLANG false positive bug here */ free_buf(header_tmp_buf); /* A zero-length message indicates the end of a stream from one @@ -1269,7 +1269,7 @@ _build_connection_okay_message(slurmd_job_t *job) msg->ref_count = 0; /* make certain it is initialized */ /* free the Buf packbuf, but not the memory to which it points */ - packbuf->head = NULL; + packbuf->head = NULL; /* CLANG false positive bug here */ free_buf(packbuf); return msg; @@ -1753,7 +1753,7 @@ _send_eof_msg(struct task_read_info *out) msg->ref_count = 0; /* make certain it is initialized */ /* free the Buf packbuf, but not the memory to which it points */ - packbuf->head = NULL; + packbuf->head = NULL; /* CLANG false positive bug here */ free_buf(packbuf); /* Add eof message to the msg_queue of all clients */ @@ -1846,7 +1846,7 @@ _task_build_message(struct task_read_info *out, slurmd_job_t *job, cbuf_t cbuf) msg->ref_count = 0; /* make certain it is initialized */ /* free the Buf packbuf, but not the memory to which it points */ - packbuf->head = NULL; + packbuf->head = NULL; /* CLANG false positive bug here */ free_buf(packbuf); debug4("Leaving _task_build_message"); -- GitLab