From 23e4707c082fbb19fa0928870e0ecbe577cdda44 Mon Sep 17 00:00:00 2001 From: Juee Himalbhai Desai Date: Mon, 19 Feb 2024 20:53:21 -0800 Subject: [PATCH] fabtests: Fix missing return value checks by adding FT_CLOSE_FID 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 --- fabtests/component/sock_test.c | 4 +++- fabtests/functional/rdm_stress.c | 10 +++++----- fabtests/multinode/src/core_coll.c | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fabtests/component/sock_test.c b/fabtests/component/sock_test.c index 9d5365cbaf4..abd9a999090 100755 --- a/fabtests/component/sock_test.c +++ b/fabtests/component/sock_test.c @@ -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; } diff --git a/fabtests/functional/rdm_stress.c b/fabtests/functional/rdm_stress.c index 4e412f18f2f..84539644d88 100644 --- a/fabtests/functional/rdm_stress.c +++ b/fabtests/functional/rdm_stress.c @@ -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; } @@ -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; @@ -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; } @@ -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; @@ -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; } diff --git a/fabtests/multinode/src/core_coll.c b/fabtests/multinode/src/core_coll.c index a8341ca9f05..96147820775 100644 --- a/fabtests/multinode/src/core_coll.c +++ b/fabtests/multinode/src/core_coll.c @@ -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;