diff mbox

staging/rdma/hfi1: Delete unnecessary checks before two function calls

Message ID 563B0F07.3090301@users.sourceforge.net (mailing list archive)
State Not Applicable
Headers show

Commit Message

SF Markus Elfring Nov. 5, 2015, 8:10 a.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Nov 2015 08:41:00 +0100

The functions "sc_return_credits" and "vfree" perform also input
parameter validation. Thus the tests around their calls are not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rdma/hfi1/file_ops.c  | 2 +-
 drivers/staging/rdma/hfi1/user_sdma.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

Comments

Dan Carpenter Nov. 5, 2015, 8:18 a.m. UTC | #1
On Thu, Nov 05, 2015 at 09:10:47AM +0100, SF Markus Elfring wrote:
> diff --git a/drivers/staging/rdma/hfi1/file_ops.c b/drivers/staging/rdma/hfi1/file_ops.c
> index aae9826..204d1d0 100644
> --- a/drivers/staging/rdma/hfi1/file_ops.c
> +++ b/drivers/staging/rdma/hfi1/file_ops.c
> @@ -313,7 +313,7 @@ static ssize_t hfi1_file_write(struct file *fp, const char __user *data,
>  	case HFI1_CMD_SDMA_STATUS_UPD:
>  		break;
>  	case HFI1_CMD_CREDIT_UPD:
> -		if (uctxt && uctxt->sc)
> +		if (uctxt)
>  			sc_return_credits(uctxt->sc);

Relying on hidden sanity checks makes the code harder to read.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/staging/rdma/hfi1/file_ops.c b/drivers/staging/rdma/hfi1/file_ops.c
index aae9826..204d1d0 100644
--- a/drivers/staging/rdma/hfi1/file_ops.c
+++ b/drivers/staging/rdma/hfi1/file_ops.c
@@ -313,7 +313,7 @@  static ssize_t hfi1_file_write(struct file *fp, const char __user *data,
 	case HFI1_CMD_SDMA_STATUS_UPD:
 		break;
 	case HFI1_CMD_CREDIT_UPD:
-		if (uctxt && uctxt->sc)
+		if (uctxt)
 			sc_return_credits(uctxt->sc);
 		break;
 	case HFI1_CMD_TID_UPDATE:
diff --git a/drivers/staging/rdma/hfi1/user_sdma.c b/drivers/staging/rdma/hfi1/user_sdma.c
index 36c838d..45f3797 100644
--- a/drivers/staging/rdma/hfi1/user_sdma.c
+++ b/drivers/staging/rdma/hfi1/user_sdma.c
@@ -473,8 +473,7 @@  int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd)
 		fd->pq = NULL;
 	}
 	if (fd->cq) {
-		if (fd->cq->comps)
-			vfree(fd->cq->comps);
+		vfree(fd->cq->comps);
 		kfree(fd->cq);
 		fd->cq = NULL;
 	}