Skip to content

Commit

Permalink
pm/hydra: Fix error checking for some libpmi functions
Browse files Browse the repository at this point in the history
libpmi functions return a pmi_errno, not a HYD_status. Make sure to
capture the value in the right variable type and perform the necessary
check on it.
  • Loading branch information
raffenet committed Jan 2, 2025
1 parent ab77d09 commit 26b2796
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/pm/hydra/mpiexec/pmiserv_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ static HYD_status handle_pmi_cmd(struct HYD_proxy *proxy, int pgid, int process_
int buflen, int pmi_version)
{
HYD_status status = HYD_SUCCESS;
int pmi_errno;

HYDU_FUNC_ENTER();

if (HYD_server_info.user_global.debug)
HYDU_dump(stdout, "[pgid: %d] got PMI command: %s\n", pgid, buf);

struct PMIU_cmd pmi;
status = PMIU_cmd_parse(buf, buflen, pmi_version, &pmi);
HYDU_ERR_POP(status, "unable to parse PMI command\n");
pmi_errno = PMIU_cmd_parse(buf, buflen, pmi_version, &pmi);
HYDU_ASSERT(!pmi_errno, status);

#if defined ENABLE_PROFILING
if (HYD_server_info.enable_profiling)
Expand Down
8 changes: 4 additions & 4 deletions src/pm/hydra/proxy/pmip_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ static HYD_status handle_pmi_cmd(struct pmip_downstream *p, char *buf, int bufle

if (handler) {
struct PMIU_cmd pmi;
status = PMIU_cmd_parse(buf, buflen, pmi_version, &pmi);
HYDU_ERR_POP(status, "unable to parse PMI command\n");
int pmi_errno = PMIU_cmd_parse(buf, buflen, pmi_version, &pmi);
HYDU_ASSERT(!pmi_errno, status);

if (HYD_pmcd_pmip.user_global.debug) {
int pgid = PMIP_pg_from_downstream(p)->pgid;
Expand Down Expand Up @@ -414,8 +414,8 @@ static HYD_status handle_pmi_response(struct pmip_pg *pg, int buflen, int pmi_ve
if (handler) {
struct PMIU_cmd pmi;
/* note: buf is modified during parsing; make sure do not forward */
status = PMIU_cmd_parse(buf, buflen, pmi_version, &pmi);
HYDU_ERR_POP(status, "unable to parse PMI command\n");
int pmi_errno = PMIU_cmd_parse(buf, buflen, pmi_version, &pmi);
HYDU_ASSERT(!pmi_errno, status);

status = handler(pg, &pmi);
HYDU_ERR_POP(status, "PMI handler returned error\n");
Expand Down
8 changes: 4 additions & 4 deletions src/pm/hydra/proxy/pmip_pmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ HYD_status fn_put(struct pmip_downstream *p, struct PMIU_cmd *pmi)
HYDU_ASSERT(!pmi_errno, status);

if (strncmp(key, "PMI_", 4) == 0) {
status = PMIU_msg_set_response_fail(pmi, &pmi_response, is_static,
1, "Keys with PMI_ prefix are reserved");
pmi_errno = PMIU_msg_set_response_fail(pmi, &pmi_response, is_static,
1, "Keys with PMI_ prefix are reserved");
HYDU_ASSERT(!pmi_errno, status);

status = send_cmd_downstream(p->pmi_fd, &pmi_response);
Expand Down Expand Up @@ -662,8 +662,8 @@ HYD_status fn_info_putnodeattr(struct pmip_downstream *p, struct PMIU_cmd *pmi)
HYDU_ASSERT(!pmi_errno, status);

if (strncmp(key, "PMI_", 4) == 0) {
status = PMIU_msg_set_response_fail(pmi, &pmi_response, is_static,
1, "Keys with PMI_ prefix are reserved");
pmi_errno = PMIU_msg_set_response_fail(pmi, &pmi_response, is_static,
1, "Keys with PMI_ prefix are reserved");
HYDU_ASSERT(!pmi_errno, status);

status = send_cmd_downstream(p->pmi_fd, &pmi_response);
Expand Down

0 comments on commit 26b2796

Please sign in to comment.