Skip to content

Commit c9ada8e

Browse files
author
Ralph Castain
committed
Silence Coverity warnings
1 parent 0b915f1 commit c9ada8e

File tree

3 files changed

+24
-31
lines changed

3 files changed

+24
-31
lines changed

opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_listener.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,8 @@ static pmix_status_t pmix_server_authenticate(pmix_pending_connection_t *pnd,
648648
pmix_output_verbose(2, pmix_globals.debug_output,
649649
"validation of client credential failed");
650650
free(msg);
651-
if (NULL != psave) {
652-
pmix_pointer_array_set_item(&pmix_server_globals.clients, psave->index, NULL);
653-
PMIX_RELEASE(psave);
654-
}
651+
pmix_pointer_array_set_item(&pmix_server_globals.clients, psave->index, NULL);
652+
PMIX_RELEASE(psave);
655653
/* send an error reply to the client */
656654
goto error;
657655
}

opal/mca/pmix/pmix2x/pmix/src/tool/pmix_tool.c

100644100755
Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,12 @@ pmix_output(0, "TOOL INIT");
218218
if (0 == strcmp(PMIX_EVENT_BASE, info[n].key)) {
219219
pmix_globals.evbase = (pmix_event_base_t*)info[n].value.data.ptr;
220220
pmix_globals.external_evbase = true;
221+
} else if (strcmp(info[i].key, PMIX_SERVER_PIDINFO) == 0) {
222+
server_pid = info[i].value.data.integer;
221223
}
222224
}
223225
}
226+
224227
/* setup the globals */
225228
pmix_globals_init();
226229
PMIX_CONSTRUCT(&pmix_client_globals.pending_requests, pmix_list_t);
@@ -254,31 +257,19 @@ pmix_output(0, "TOOL INIT");
254257
}
255258
}
256259

257-
/* setup the path to the daemon rendezvous point */
258-
memset(&address, 0, sizeof(struct sockaddr_un));
259-
address.sun_family = AF_UNIX;
260-
/* Get first 10 char's of hostname to match what the server is doing */
261-
gethostname(hostname, hostnamelen);
262-
263-
/* Get the local hostname, and look for a file named
264-
* /tmp/pmix.hostname.tool - this file will contain
265-
* the URI where the server is listening. The URI consists
266-
* of 3 parts - the code below will parse the string read
267-
* from the file and connect accordingly */
260+
/* setup the path to the daemon rendezvous point */
261+
memset(&address, 0, sizeof(struct sockaddr_un));
262+
address.sun_family = AF_UNIX;
263+
/* Get first 10 char's of hostname to match what the server is doing */
264+
gethostname(hostname, hostnamelen);
268265

269-
for (i = 0; i < (int)ninfo; i++) {
270-
if (strcmp(info[i].key, PMIX_SERVER_PIDINFO) == 0) {
271-
server_pid = info[i].value.data.integer;
272-
break;
273-
}
274-
}
275266
/* if they gave us a specific pid, then look for that
276267
* particular server - otherwise, see if there is only
277268
* one on this node and default to it */
278269
if (server_pid != -1) {
279270
snprintf(address.sun_path, sizeof(address.sun_path)-1, "%s/pmix.%s.%d", tdir, hostname, server_pid);
280271
/* if the rendezvous file doesn't exist, that's an error */
281-
if (0 != access(address.sun_path, R_OK)) {
272+
if (0 != access(address.sun_path, R_OK)) {
282273
pmix_output_close(pmix_globals.debug_output);
283274
pmix_output_finalize();
284275
pmix_class_finalize();
@@ -294,13 +285,16 @@ pmix_output(0, "TOOL INIT");
294285
}
295286
/* search the entries for something that starts with pmix.hostname */
296287
if (0 > asprintf(&tmp, "pmix.%s", hostname)) {
288+
closedir(cur_dirp);
297289
return PMIX_ERR_NOMEM;
298290
}
299291
evar = NULL;
300292
while (NULL != (dir_entry = readdir(cur_dirp))) {
301293
if (0 == strncmp(dir_entry->d_name, tmp, strlen(tmp))) {
302294
/* found one - if more than one, then that's an error */
303295
if (NULL != evar) {
296+
closedir(cur_dirp);
297+
free(evar);
304298
free(tmp);
305299
pmix_output_close(pmix_globals.debug_output);
306300
pmix_output_finalize();
@@ -833,24 +827,23 @@ static pmix_status_t usock_connect(struct sockaddr_un *addr, int *fd)
833827
"timeout connecting to server");
834828
CLOSE_THE_SOCKET(sd);
835829
continue;
836-
}
837-
838-
/* Some kernels (Linux 2.6) will automatically software
839-
abort a connection that was ECONNREFUSED on the last
840-
attempt, without even trying to establish the
841-
connection. Handle that case in a semi-rational
842-
way by trying twice before giving up */
843-
else if (ECONNABORTED == pmix_socket_errno) {
830+
} else if (ECONNABORTED == pmix_socket_errno) {
831+
/* Some kernels (Linux 2.6) will automatically software
832+
abort a connection that was ECONNREFUSED on the last
833+
attempt, without even trying to establish the
834+
connection. Handle that case in a semi-rational
835+
way by trying twice before giving up */
844836
pmix_output_verbose(2, pmix_globals.debug_output,
845837
"connection to server aborted by OS - retrying");
846838
CLOSE_THE_SOCKET(sd);
847839
continue;
848840
} else {
849841
pmix_output_verbose(2, pmix_globals.debug_output,
850842
"Failed to connect, errno = %d, err= %s\n", errno, strerror(errno));
843+
CLOSE_THE_SOCKET(sd);
851844
continue;
845+
}
852846
}
853-
}
854847
/* otherwise, the connect succeeded - so break out of the loop */
855848
break;
856849
}

orte/orted/pmix/pmix_server_gen.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ static void _toolconn(int sd, short args, void *cbdata)
434434
/* otherwise, we have to send the request to the HNP.
435435
* Eventually, when we switch to nspace instead of an
436436
* integer jobid, we'll just locally assign this value */
437+
tool.jobid = ORTE_JOBID_INVALID;
438+
tool.vpid = ORTE_VPID_INVALID;
437439
if (NULL != cd->toolcbfunc) {
438440
cd->toolcbfunc(ORTE_ERR_NOT_SUPPORTED, tool, cd->cbdata);
439441
}

0 commit comments

Comments
 (0)