[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 49/59] rdma/rdma_rm.c: remove unneeded label in rdma_rm_alloc_

From: Daniel Henrique Barboza
Subject: [PATCH v1 49/59] rdma/rdma_rm.c: remove unneeded label in rdma_rm_alloc_pd()
Date: Mon, 6 Jan 2020 15:24:15 -0300

'out' label can be replaced by 'return ret'. Since 'ret' will
be set to -ENOMEM in 'goto' time, we can replace it to
'return -ENOMEM'.

After this change, the 'ret' var is used to store the
result of rdma_backend_create_pd(), see if it's not zero,
then 'ret' is set to -EIO before the jump to out_tbl_dealloc.
-EIO is the only error being thrown by out_tbl_dealloc too.
This means we can go a step further in the code simplification
by also removing the 'ret' variable and making out_tbl_dealloc
return -EIO directly.

CC: Yuval Shaia <address@hidden>
CC: Marcel Apfelbaum <address@hidden>
Signed-off-by: Daniel Henrique Barboza <address@hidden>
 hw/rdma/rdma_rm.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c
index 1524dfaeaa..f049fda38a 100644
--- a/hw/rdma/rdma_rm.c
+++ b/hw/rdma/rdma_rm.c
@@ -161,16 +161,13 @@ int rdma_rm_alloc_pd(RdmaDeviceResources *dev_res, 
RdmaBackendDev *backend_dev,
                      uint32_t *pd_handle, uint32_t ctx_handle)
     RdmaRmPD *pd;
-    int ret = -ENOMEM;
     pd = rdma_res_tbl_alloc(&dev_res->pd_tbl, pd_handle);
     if (!pd) {
-        goto out;
+        return -ENOMEM;
-    ret = rdma_backend_create_pd(backend_dev, &pd->backend_pd);
-    if (ret) {
-        ret = -EIO;
+    if (rdma_backend_create_pd(backend_dev, &pd->backend_pd)) {
         goto out_tbl_dealloc;
@@ -180,9 +177,7 @@ int rdma_rm_alloc_pd(RdmaDeviceResources *dev_res, 
RdmaBackendDev *backend_dev,
     rdma_res_tbl_dealloc(&dev_res->pd_tbl, *pd_handle);
-    return ret;
+    return -EIO;
 RdmaRmPD *rdma_rm_get_pd(RdmaDeviceResources *dev_res, uint32_t pd_handle)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]