Skip to content

Commit 4ee4faf

Browse files
committed
Silence Coverity warnings
490148 490147 490146 372371 488173 Signed-off-by: Ralph Castain <[email protected]>
1 parent b256454 commit 4ee4faf

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

src/mca/ras/gridengine/ras_gridengine_module.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,31 @@ prte_ras_base_module_t prte_ras_gridengine_module = {NULL, prte_ras_gridengine_a
6363
*/
6464
static int prte_ras_gridengine_allocate(prte_job_t *jdata, pmix_list_t *nodelist)
6565
{
66-
char *pe_hostfile = getenv("PE_HOSTFILE");
67-
char *job_id = getenv("JOB_ID");
66+
char *pe_hostfile;
67+
char *job_id;
6868
char buf[1024], *tok, *num, *queue, *arch, *ptr;
6969
int rc;
7070
FILE *fp;
7171
prte_node_t *node;
7272
bool found;
7373
PRTE_HIDE_UNUSED_PARAMS(jdata);
7474

75+
pe_hostfile = getenv("PE_HOSTFILE");
76+
job_id = getenv("JOB_ID");
77+
78+
if (NULL == pe_hostfile || NULL == job_id) {
79+
return PRTE_ERR_TAKE_NEXT_OPTION;
80+
}
81+
7582
/* show the Grid Engine's JOB_ID */
76-
if (prte_mca_ras_gridengine_component.show_jobid || prte_mca_ras_gridengine_component.verbose != -1) {
83+
if (prte_mca_ras_gridengine_component.show_jobid ||
84+
prte_mca_ras_gridengine_component.verbose != -1) {
7785
pmix_output(0, "ras:gridengine: JOB_ID: %s", job_id);
7886
}
7987

8088
/* check the PE_HOSTFILE before continuing on */
81-
if (!(fp = fopen(pe_hostfile, "r"))) {
89+
fp = fopen(pe_hostfile, "r");
90+
if (NULL == fp) {
8291
pmix_show_help("help-ras-gridengine.txt", "cannot-read-pe-hostfile", true, pe_hostfile,
8392
strerror(errno));
8493
rc = PRTE_ERROR;
@@ -129,7 +138,9 @@ static int prte_ras_gridengine_allocate(prte_job_t *jdata, pmix_list_t *nodelist
129138
} /* finished reading the $PE_HOSTFILE */
130139

131140
cleanup:
132-
fclose(fp);
141+
if (NULL != fp) {
142+
fclose(fp);
143+
}
133144

134145
/* in gridengine, if we didn't find anything, then something
135146
* is wrong. The user may not have indicated this was a parallel

src/mca/rmaps/seq/rmaps_seq.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,8 @@ static int prte_rmaps_seq_map(prte_job_t *jdata,
137137
prte_app_context_t *app;
138138
int i, n;
139139
int32_t j;
140-
pmix_list_item_t *item;
141140
prte_node_t *node, *nd;
142-
seq_node_t *sq, *save = NULL, *seq;
141+
seq_node_t *sq, *save = NULL, *seq, *seq2;
143142
pmix_rank_t vpid, apprank;
144143
int32_t num_nodes;
145144
int rc;
@@ -207,9 +206,6 @@ static int prte_rmaps_seq_map(prte_job_t *jdata,
207206
/* start at the beginning... */
208207
vpid = 0;
209208
jdata->num_procs = 0;
210-
if (0 < pmix_list_get_size(&default_seq_list)) {
211-
save = (seq_node_t *) pmix_list_get_first(&default_seq_list);
212-
}
213209

214210
/* cycle through the app_contexts, mapping them sequentially */
215211
for (i = 0; i < jdata->apps->size; i++) {
@@ -293,6 +289,9 @@ static int prte_rmaps_seq_map(prte_job_t *jdata,
293289
goto process;
294290
}
295291

292+
/* if we get here, then there were no app-level directives, so try to use the
293+
* default hostfile list */
294+
296295
if (0 < pmix_list_get_size(&default_seq_list)) {
297296
pmix_output_verbose(5, prte_rmaps_base_framework.framework_output,
298297
"mca:rmaps:seq: using default hostfile nodes on app %s", app->app);
@@ -308,18 +307,16 @@ static int prte_rmaps_seq_map(prte_job_t *jdata,
308307
process:
309308
/* check for nolocal and remove the head node, if required */
310309
if (PRTE_GET_MAPPING_DIRECTIVE(map->mapping) & PRTE_MAPPING_NO_USE_LOCAL) {
311-
for (item = pmix_list_get_first(seq_list); item != pmix_list_get_end(seq_list);
312-
item = pmix_list_get_next(item)) {
313-
seq = (seq_node_t *) item;
310+
PMIX_LIST_FOREACH_SAFE(seq, seq2, seq_list, seq_node_t) {
314311
/* need to check ifislocal because the name in the
315312
* hostfile may not have been FQDN, while name returned
316313
* by gethostname may have been (or vice versa)
317314
*/
318315
if (prte_check_host_is_local(seq->hostname)) {
319316
pmix_output_verbose(5, prte_rmaps_base_framework.framework_output,
320317
"mca:rmaps:seq: removing head node %s", seq->hostname);
321-
pmix_list_remove_item(seq_list, item);
322-
PMIX_RELEASE(item); /* "un-retain" it */
318+
pmix_list_remove_item(seq_list, &seq->super);
319+
PMIX_RELEASE(seq); /* "un-retain" it */
323320
}
324321
}
325322
}
@@ -345,7 +342,14 @@ static int prte_rmaps_seq_map(prte_job_t *jdata,
345342
}
346343

347344
if (seq_list == &default_seq_list) {
348-
sq = save;
345+
/* we don't want to start in the same place for every app, so take
346+
* the next item in the list - if this is the first time we are
347+
* using the default list, then start at its beginning */
348+
if (NULL == save) {
349+
sq = (seq_node_t *) pmix_list_get_first(&default_seq_list);
350+
} else {
351+
sq = save;
352+
}
349353
} else {
350354
sq = (seq_node_t *) pmix_list_get_first(seq_list);
351355
}

src/prted/pmix/pmix_server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,7 @@ static void pmix_server_sched(int status, pmix_proc_t *sender,
19471947
pmix_status_t rc = PMIX_SUCCESS;
19481948
uint8_t cmd;
19491949
int32_t cnt;
1950-
size_t ninfo;
1950+
size_t ninfo = 0;
19511951
pmix_alloc_directive_t allocdir;
19521952
uint32_t sessionID;
19531953
pmix_info_t *info = NULL;

src/tools/prted/prted.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
191191
pmix_data_buffer_t pbuf, *wbuf;
192192
pmix_byte_object_t pbo;
193193
int8_t flag;
194-
char **nonlocal = NULL, *aliases, *personality;
194+
char **nonlocal, *aliases, *personality;
195195
int n;
196196
pmix_value_t *vptr;
197197
char **pargv;
@@ -571,6 +571,7 @@ int main(int argc, char *argv[])
571571
}
572572

573573
/* include any non-loopback aliases for this node */
574+
nonlocal = NULL;
574575
for (n = 0; NULL != prte_process_info.aliases[n]; n++) {
575576
if (0 != strcmp(prte_process_info.aliases[n], "localhost") &&
576577
0 != strcmp(prte_process_info.aliases[n], "127.0.0.1") &&

0 commit comments

Comments
 (0)