Skip to content

Commit

Permalink
fabtests: Fix missing return value checks by adding FT_CLOSE_FID
Browse files Browse the repository at this point in the history
Coverity flagged missing error handling for fi_close.
This patch takes care of error handling by calling FT_CLOSE_FID
instead of fi_close which handles return value check.

For component/sock_test.c:
Send function returns the number of bytes sent and here since
we are sending only one byte, we will return -errno if return
code is less that 0.

Signed-off-by: Juee Himalbhai Desai <juee.himalbhai.desai@intel.com>
  • Loading branch information
Juee14Desai authored and j-xiong committed Feb 21, 2024
1 parent 7613257 commit 23e4707
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion fabtests/component/sock_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,9 @@ static int run_server(void)
if (ret)
return ret;

send(fds[0], &c, 1, 0);
ret = send(fds[0], &c, 1, 0);
if (ret < 0)
return -errno;
return 0;
}

Expand Down
10 changes: 5 additions & 5 deletions fabtests/functional/rdm_stress.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ static int rpc_reg_buf(struct rpc_ctrl *ctrl, size_t size, uint64_t access)
return FI_SUCCESS;

close:
fi_close(&ctrl->mr->fid);
FT_CLOSE_FID(ctrl->mr);
return ret;
}

Expand Down Expand Up @@ -494,7 +494,7 @@ static int rpc_read_req(struct rpc_ctrl *ctrl)
return 0;

close:
fi_close(&ctrl->mr->fid);
FT_CLOSE_FID(ctrl->mr);
free:
free(ctrl->buf);
return ret;
Expand All @@ -515,7 +515,7 @@ static int rpc_read_resp(struct rpc_ctrl *ctrl)
ret = ft_check_buf(&req->buf[req->offset], req->size);

close:
fi_close(&req->mr->fid);
FT_CLOSE_FID(req->mr);
free(req->buf);
return ret;
}
Expand Down Expand Up @@ -551,7 +551,7 @@ static int rpc_write_req(struct rpc_ctrl *ctrl)
return 0;

close:
fi_close(&ctrl->mr->fid);
FT_CLOSE_FID(ctrl->mr);
free:
free(ctrl->buf);
return ret;
Expand All @@ -572,7 +572,7 @@ static int rpc_write_resp(struct rpc_ctrl *ctrl)
ret = ft_check_buf(&req->buf[req->offset], req->size);

close:
fi_close(&req->mr->fid);
FT_CLOSE_FID(req->mr);
free(req->buf);
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion fabtests/multinode/src/core_coll.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static int coll_teardown(void)

ret = fi_close(&coll_mc->fid);
if (ret)
fi_close(&av_set->fid);
FT_CLOSE_FID(av_set);
else
ret = fi_close(&av_set->fid);
return ret;
Expand Down

0 comments on commit 23e4707

Please sign in to comment.