All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Sam Muhammed <jane.pnx9@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH v2 1/7] Staging: kpc2000: kpc_dma: Remove comparison to NULL.
Date: Mon, 30 Mar 2020 03:04:11 +0200	[thread overview]
Message-ID: <20200330030346.6420ddc6@elisabeth> (raw)
In-Reply-To: <f344afba0a8bb0413941a63678688435f04a96b4.1585143581.git.jane.pnx9@gmail.com>

On Wed, 25 Mar 2020 10:26:36 -0400
Sam Muhammed <jane.pnx9@gmail.com> wrote:

> Comparison to NULL been used across the driver,
> remove them and use (!var) instead.
> 
> Checkpatch.pl: CHECK:
> Comparison to NULL could be written "!desc"... etc
> 
> Signed-off-by: Sam Muhammed <jane.pnx9@gmail.com>
> ---
> Changes in v2:
> - None.
> 
>  drivers/staging/kpc2000/kpc_dma/dma.c            |  2 +-
>  drivers/staging/kpc2000/kpc_dma/fileops.c        | 12 ++++++------
>  drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h |  4 ++--
>  3 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c
> index 51a4dd534a0d..4bfbc717bc07 100644
> --- a/drivers/staging/kpc2000/kpc_dma/dma.c
> +++ b/drivers/staging/kpc2000/kpc_dma/dma.c
> @@ -236,7 +236,7 @@ int  count_descriptors_available(struct kpc_dma_device *eng)
>  	struct kpc_dma_descriptor *cur = eng->desc_next;
> 
>  	while (cur != eng->desc_completed) {
> -		BUG_ON(cur == NULL);
> +		BUG_ON(!cur);
>  		count++;
>  		cur = cur->Next;
>  	}
> diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c
> index 40525540dde6..5eb6c5f24feb 100644
> --- a/drivers/staging/kpc2000/kpc_dma/fileops.c
> +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c
> @@ -124,7 +124,7 @@ static int kpc_dma_transfer(struct dev_private_data *priv,
>  		pcnt = count_parts_for_sge(sg);
>  		for (p = 0 ; p < pcnt ; p++) {
>  			// Fill out the descriptor
> -			BUG_ON(desc == NULL);
> +			BUG_ON(!desc);
>  			clear_desc(desc);
>  			if (p != pcnt-1) {
>  				desc->DescByteCount = 0x80000;
> @@ -203,11 +203,11 @@ void  transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags)
>  {
>  	unsigned int i;
> 
> -	BUG_ON(acd == NULL);
> -	BUG_ON(acd->user_pages == NULL);
> -	BUG_ON(acd->sgt.sgl == NULL);
> -	BUG_ON(acd->ldev == NULL);
> -	BUG_ON(acd->ldev->pldev == NULL);
> +	BUG_ON(!acd);
> +	BUG_ON(!acd->user_pages);
> +	BUG_ON(!acd->sgt.sgl);
> +	BUG_ON(!acd->ldev);
> +	BUG_ON(!acd->ldev->pldev);

I've seen some tool reporting this (perhaps Coccinelle?): with
x == NULL, BUG_ON(!x) causes a kernel panic just like dereferencing x.
So the first statement in e.g.:

	BUG_ON(!acd);
	BUG_ON(!acd->user_pages);

is redundant. This change wouldn't be related to this patch, though.

-- 
Stefano



  reply	other threads:[~2020-03-30  1:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 14:26 [PATCH v2 0/7] Staging: kpc2000: kpc_dma: Clear Misc Checkpatch.pl WARNINGS Sam Muhammed
2020-03-25 14:26 ` [PATCH v2 1/7] Staging: kpc2000: kpc_dma: Remove comparison to NULL Sam Muhammed
2020-03-30  1:04   ` Stefano Brivio [this message]
2020-03-30 10:48     ` [Outreachy kernel] " Sam Muhammed
2020-03-30 10:58       ` Julia Lawall
2020-03-30 11:02         ` Sam Muhammed
2020-03-30 13:55       ` Stefano Brivio
2020-03-30 16:33         ` Sam Muhammed
2020-03-25 14:26 ` [PATCH v2 2/7] Staging: kpc2000: kpc_dma: Use sizeof(*var) in kzalloc() Sam Muhammed
2020-03-30  1:04   ` [Outreachy kernel] " Stefano Brivio
2020-03-30 10:45     ` Sam Muhammed
2020-03-30 12:56       ` Stefano Brivio
2020-03-30 13:10         ` Sam Muhammed
2020-03-30 13:51           ` Stefano Brivio
2020-03-25 14:26 ` [PATCH v2 3/7] Staging: kpc2000: kpc_dma: Remove unnecessary braces Sam Muhammed
2020-03-25 14:26 ` [PATCH v2 4/7] Staging: kpc2000: kpc_dma: Include the preferred header Sam Muhammed
2020-03-25 14:26 ` [PATCH v2 5/7] Staging: kpc2000: kpc_dma: Use the SPDK comment style Sam Muhammed
2020-03-25 14:26 ` [PATCH v2 6/7] Staging: kpc2000: kpc_dma: Use kcalloc over kzalloc Sam Muhammed
2020-03-25 14:26 ` [PATCH v2 7/7] Staging: kpc2000: kpc_dma: Use spaces around operators Sam Muhammed
2020-03-30  1:04 ` [Outreachy kernel] [PATCH v2 0/7] Staging: kpc2000: kpc_dma: Clear Misc Checkpatch.pl WARNINGS Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200330030346.6420ddc6@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jane.pnx9@gmail.com \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.