Skip to content

Commit fb15a60

Browse files
committed
Silence more Coverity warnings
489769 489768 488242 488236 488235 488224 488213 488203 488198 488195 488192 488185 488179 Signed-off-by: Ralph Castain <[email protected]>
1 parent 8909c26 commit fb15a60

File tree

9 files changed

+74
-27
lines changed

9 files changed

+74
-27
lines changed

src/mca/ess/base/ess_base_bootstrap.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,15 @@ int prte_ess_base_bootstrap(void)
151151

152152
/* identify and cache the option */
153153
if (0 == strcmp(line, "ClusterName")) {
154+
if (NULL != cluster) {
155+
free(cluster);
156+
}
154157
cluster = strdup(ptr);
155158

156159
} else if (0 == strcmp(line, "DVMControllerHost")) {
160+
if (NULL != ctrlhost) {
161+
free(ctrlhost);
162+
}
157163
ctrlhost = strdup(ptr);
158164

159165
} else if (0 == strcmp(line, "DVMControllerPort")) {
@@ -163,18 +169,33 @@ int prte_ess_base_bootstrap(void)
163169
prtedport = strtoul(ptr, NULL, 10);
164170

165171
} else if (0 == strcmp(line, "DVMNodes")) {
172+
if (NULL == dvmnodes) {
173+
free(dvmnodes);
174+
}
166175
dvmnodes = strdup(ptr);
167176

168177
} else if (0 == strcmp(line, "DVMTempDir")) {
178+
if (NULL == dvmtmpdir) {
179+
free(dvmtmpdir);
180+
}
169181
dvmtmpdir = strdup(ptr);
170182

171183
} else if (0 == strcmp(line, "SessionTmpDir")) {
184+
if (NULL != sessiontmpdir) {
185+
free(sessiontmpdir);
186+
}
172187
sessiontmpdir = strdup(ptr);
173188

174189
} else if (0 == strcmp(line, "ControllerLogPath")) {
190+
if (NULL != ctrllogpath) {
191+
free(ctrllogpath);
192+
}
175193
ctrllogpath = strdup(ptr);
176194

177195
} else if (0 == strcmp(line, "PRTEDLogPath")) {
196+
if (NULL != prtedlogpath) {
197+
free(prtedlogpath);
198+
}
178199
prtedlogpath = strdup(ptr);
179200
}
180201
free(line);

src/mca/grpcomm/direct/grpcomm_direct_group.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,19 +586,43 @@ void prte_grpcomm_direct_grp_recv(int status, pmix_proc_t *sender,
586586
PMIx_Info_list_convert(coll->grpinfo, &darray);
587587
info = (pmix_info_t*)darray.array;
588588
ninfo = darray.size;
589-
PMIx_Data_pack(NULL, reply, &ninfo, 1, PMIX_SIZE);
589+
rc = PMIx_Data_pack(NULL, reply, &ninfo, 1, PMIX_SIZE);
590+
if (PMIX_SUCCESS != rc) {
591+
PMIX_ERROR_LOG(rc);
592+
PMIX_DATA_BUFFER_RELEASE(reply);
593+
PMIX_RELEASE(sig);
594+
return;
595+
}
590596
if (0 < ninfo) {
591-
PMIx_Data_pack(NULL, reply, info, ninfo, PMIX_INFO);
597+
rc = PMIx_Data_pack(NULL, reply, info, ninfo, PMIX_INFO);
598+
if (PMIX_SUCCESS != rc) {
599+
PMIX_ERROR_LOG(rc);
600+
PMIX_DATA_BUFFER_RELEASE(reply);
601+
PMIX_RELEASE(sig);
602+
return;
603+
}
592604
}
593605
PMIX_DATA_ARRAY_DESTRUCT(&darray);
594606

595607
// pack any endpts
596608
PMIx_Info_list_convert(coll->endpts, &darray);
597609
info = (pmix_info_t*)darray.array;
598610
ninfo = darray.size;
599-
PMIx_Data_pack(NULL, reply, &ninfo, 1, PMIX_SIZE);
611+
rc = PMIx_Data_pack(NULL, reply, &ninfo, 1, PMIX_SIZE);
612+
if (PMIX_SUCCESS != rc) {
613+
PMIX_ERROR_LOG(rc);
614+
PMIX_DATA_BUFFER_RELEASE(reply);
615+
PMIX_RELEASE(sig);
616+
return;
617+
}
600618
if (0 < ninfo) {
601-
PMIx_Data_pack(NULL, reply, info, ninfo, PMIX_INFO);
619+
rc = PMIx_Data_pack(NULL, reply, info, ninfo, PMIX_INFO);
620+
if (PMIX_SUCCESS != rc) {
621+
PMIX_ERROR_LOG(rc);
622+
PMIX_DATA_BUFFER_RELEASE(reply);
623+
PMIX_RELEASE(sig);
624+
return;
625+
}
602626
}
603627
PMIX_DATA_ARRAY_DESTRUCT(&darray);
604628
}

src/mca/rmaps/base/rmaps_base_frame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ int prte_rmaps_base_set_mapping_policy(prte_job_t *jdata, char *inspec)
542542
cptr = strdup(ck[0]);
543543
*ptr = '='; // restore the option
544544
++ptr;
545-
if (NULL == ptr) {
545+
if ('\0' == *ptr) {
546546
/* malformed option */
547547
pmix_show_help("help-prte-rmaps-base.txt", "unrecognized-policy",
548548
true, "mapping", ck[0]);

src/mca/rmaps/round_robin/rmaps_rr_mappers.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,7 @@ int prte_rmaps_rr_bycpu(prte_job_t *jdata, prte_app_context_t *app,
545545
if (PRTE_ERR_SILENT != rc) {
546546
pmix_show_help("help-prte-rmaps-rr.txt",
547547
"prte-rmaps-rr:not-enough-cpus", true,
548-
(NULL == app) ? "N/A" : app->app,
549-
(NULL == app) ? -1 : app->num_procs,
550-
savecpuset);
548+
app->app, app->num_procs, savecpuset);
551549
}
552550
if (NULL != savecpuset) {
553551
free(savecpuset);

src/mca/schizo/ompi/schizo_ompi.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -522,19 +522,19 @@ static int parse_cli(char **argv, pmix_cli_result_t *results,
522522
results, "help-schizo-ompi.txt");
523523
if (PMIX_SUCCESS != rc) {
524524
PMIX_ARGV_FREE_COMPAT(pargv);
525-
if (PMIX_OPERATION_SUCCEEDED == rc) {
526-
/* pmix cmd line interpreter output result
527-
* successfully - usually means version or
528-
* some other stock output was generated */
529-
return PRTE_OPERATION_SUCCEEDED;
530-
}
531-
if(warn) {
525+
if (warn) {
532526
for(n = 0; n < cur_caught_pos; n++) {
533527
free(caught_single_dashes[n]);
534528
}
535529
free(caught_single_dashes);
536530
free(caught_positions);
537531
}
532+
if (PMIX_OPERATION_SUCCEEDED == rc) {
533+
/* pmix cmd line interpreter output result
534+
* successfully - usually means version or
535+
* some other stock output was generated */
536+
return PRTE_OPERATION_SUCCEEDED;
537+
}
538538
return prte_pmix_convert_status(rc);
539539
}
540540

@@ -587,23 +587,23 @@ static int parse_cli(char **argv, pmix_cli_result_t *results,
587587
free(orig_args);
588588
free(corrected_args);
589589
}
590+
}
591+
592+
// cleanup
593+
if (warn) {
590594
for(n = 0; n < cur_caught_pos; n++) {
591595
free(caught_single_dashes[n]);
592596
}
593597
free(caught_single_dashes);
598+
caught_single_dashes = NULL;
594599
free(caught_positions);
600+
caught_positions = NULL;
595601
}
596-
602+
597603
PMIX_ARGV_FREE_COMPAT(pargv);
598604
/* check for deprecated options - warn and convert them */
599605
rc = convert_deprecated_cli(results, silent);
600606
if (PRTE_SUCCESS != rc) {
601-
if (NULL != caught_positions) {
602-
free(caught_positions);
603-
}
604-
if (NULL != caught_single_dashes) {
605-
free(caught_single_dashes);
606-
}
607607
return rc;
608608
}
609609

src/mca/state/base/state_base_options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ int prte_state_base_set_runtime_options(prte_job_t *jdata, char *spec)
260260
&flag, PMIX_BOOL);
261261

262262
} else if (PMIX_CHECK_CLI_OPTION(options[n], PRTE_CLI_MAX_RESTARTS)) {
263-
if ('\0' == *ptr) {
263+
if (NULL == ptr || '\0' == *ptr) {
264264
/* missing the value */
265265
pmix_show_help("help-prte-rmaps-base.txt", "missing-value", true,
266266
"runtime options", options[n], "empty");

src/pmix/pmix-internal.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,13 @@ static inline __prte_attribute_always_inline__ void pmix_proc_hton_intr(pmix_pro
100100
#define PRTE_PMIX_CONSTRUCT_LOCK(l) \
101101
do { \
102102
PMIX_CONSTRUCT(&(l)->mutex, pmix_mutex_t); \
103+
pmix_mutex_lock(&(l)->mutex); \
103104
pthread_cond_init(&(l)->cond, NULL); \
104105
(l)->active = true; \
105106
(l)->status = 0; \
106107
(l)->msg = NULL; \
107108
PMIX_POST_OBJECT((l)); \
109+
pmix_mutex_unlock(&(l)->mutex); \
108110
} while (0)
109111

110112
#define PRTE_PMIX_DESTRUCT_LOCK(l) \
@@ -163,15 +165,15 @@ static inline __prte_attribute_always_inline__ void pmix_proc_hton_intr(pmix_pro
163165
# define PRTE_PMIX_RELEASE_THREAD(lck) \
164166
do { \
165167
(lck)->active = false; \
166-
pthread_cond_broadcast(&(lck)->cond); \
168+
pthread_cond_signal(&(lck)->cond); \
167169
pmix_mutex_unlock(&(lck)->mutex); \
168170
} while (0)
169171
#else
170172
# define PRTE_PMIX_RELEASE_THREAD(lck) \
171173
do { \
172174
assert(0 != pmix_mutex_trylock(&(lck)->mutex)); \
173175
(lck)->active = false; \
174-
pthread_cond_broadcast(&(lck)->cond); \
176+
pthread_cond_signal(&(lck)->cond); \
175177
pmix_mutex_unlock(&(lck)->mutex); \
176178
} while (0)
177179
#endif
@@ -181,7 +183,7 @@ static inline __prte_attribute_always_inline__ void pmix_proc_hton_intr(pmix_pro
181183
pmix_mutex_lock(&(lck)->mutex); \
182184
(lck)->active = false; \
183185
PMIX_POST_OBJECT(lck); \
184-
pthread_cond_broadcast(&(lck)->cond); \
186+
pthread_cond_signal(&(lck)->cond); \
185187
pmix_mutex_unlock(&(lck)->mutex); \
186188
} while (0)
187189

src/prted/pmix/pmix_server.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,9 @@ static void pmix_server_dmdx_recv(int status, pmix_proc_t *sender,
13891389
if (NULL != info) {
13901390
for (sz = 0; sz < ninfo; sz++) {
13911391
if (PMIX_CHECK_KEY(&info[sz], PMIX_REQUIRED_KEY)) {
1392+
if (NULL != key) {
1393+
free(key);
1394+
}
13921395
key = strdup(info[sz].value.data.string);
13931396
continue;
13941397
}

src/prted/pmix/pmix_server_dyn.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,6 @@ int prte_pmix_xfer_app(prte_job_t *jdata, pmix_app_t *papp)
714714
app->app = strdup(papp->cmd);
715715
} else if (NULL == papp->argv || NULL == papp->argv[0]) {
716716
PRTE_ERROR_LOG(PRTE_ERR_BAD_PARAM);
717-
PMIX_RELEASE(jdata);
718717
return PRTE_ERR_BAD_PARAM;
719718
} else {
720719
app->app = strdup(papp->argv[0]);

0 commit comments

Comments
 (0)