diff mbox series

[v2] scsi: Replace printk+WARN_ON by WARN macro

Message ID Y7sj22gCmnYqTzP4@ubun2204.myguest.virtualbox.org (mailing list archive)
State New, archived
Headers show
Series [v2] scsi: Replace printk+WARN_ON by WARN macro | expand

Commit Message

Deepak R Varma Jan. 8, 2023, 8:13 p.m. UTC
A combination of printk() followed by WARN_ON() macro can be simplified
using a single WARN(1, ...) macro. Patch change suggested by warn.cocci
Coccinelle semantic patch.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
Changes in v2:
   - Remove printk() from the WARN macro to avoid build warning
   - I missed to build the change before sending the earlier version which
     results in a build error due to incorrect brace balancing. Fixed it.

 drivers/scsi/initio.c   | 3 +--
 drivers/scsi/scsi_lib.c | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

Comments

Deepak R Varma Jan. 22, 2023, 7:16 p.m. UTC | #1
On Mon, Jan 09, 2023 at 01:43:15AM +0530, Deepak R Varma wrote:
> A combination of printk() followed by WARN_ON() macro can be simplified
> using a single WARN(1, ...) macro. Patch change suggested by warn.cocci
> Coccinelle semantic patch.
> 
> Signed-off-by: Deepak R Varma <drv@mailo.com>
> ---
> Changes in v2:
>    - Remove printk() from the WARN macro to avoid build warning
>    - I missed to build the change before sending the earlier version which
>      results in a build error due to incorrect brace balancing. Fixed it.

Hello,
May I request a review and feedback comments on this patch proposal?

Thank you,
./drv

> 
>  drivers/scsi/initio.c   | 3 +--
>  drivers/scsi/scsi_lib.c | 6 ++----
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
> index 375261d67619..fea591d9d292 100644
> --- a/drivers/scsi/initio.c
> +++ b/drivers/scsi/initio.c
> @@ -2738,8 +2738,7 @@ static void i91uSCBPost(u8 * host_mem, u8 * cblk_mem)
>  	host = (struct initio_host *) host_mem;
>  	cblk = (struct scsi_ctrl_blk *) cblk_mem;
>  	if ((cmnd = cblk->srb) == NULL) {
> -		printk(KERN_ERR "i91uSCBPost: SRB pointer is empty\n");
> -		WARN_ON(1);
> +		WARN(1, KERN_ERR "i91uSCBPost: SRB pointer is empty\n");
>  		initio_release_scb(host, cblk);	/* Release SCB for current channel */
>  		return;
>  	}
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 9ed1ebcb7443..0f1e9ee4591b 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -3009,10 +3009,8 @@ void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int sg_count,
>  	}
>  
>  	if (unlikely(i == sg_count)) {
> -		printk(KERN_ERR "%s: Bytes in sg: %zu, requested offset %zu, "
> -			"elements %d\n",
> -		       __func__, sg_len, *offset, sg_count);
> -		WARN_ON(1);
> +		WARN(1, KERN_ERR "%s: Bytes in sg: %zu, requested offset %zu, elements %d\n",
> +				__func__, sg_len, *offset, sg_count);
>  		return NULL;
>  	}
>  
> -- 
> 2.34.1
> 
> 
>
diff mbox series

Patch

diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index 375261d67619..fea591d9d292 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -2738,8 +2738,7 @@  static void i91uSCBPost(u8 * host_mem, u8 * cblk_mem)
 	host = (struct initio_host *) host_mem;
 	cblk = (struct scsi_ctrl_blk *) cblk_mem;
 	if ((cmnd = cblk->srb) == NULL) {
-		printk(KERN_ERR "i91uSCBPost: SRB pointer is empty\n");
-		WARN_ON(1);
+		WARN(1, KERN_ERR "i91uSCBPost: SRB pointer is empty\n");
 		initio_release_scb(host, cblk);	/* Release SCB for current channel */
 		return;
 	}
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 9ed1ebcb7443..0f1e9ee4591b 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -3009,10 +3009,8 @@  void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int sg_count,
 	}
 
 	if (unlikely(i == sg_count)) {
-		printk(KERN_ERR "%s: Bytes in sg: %zu, requested offset %zu, "
-			"elements %d\n",
-		       __func__, sg_len, *offset, sg_count);
-		WARN_ON(1);
+		WARN(1, KERN_ERR "%s: Bytes in sg: %zu, requested offset %zu, elements %d\n",
+				__func__, sg_len, *offset, sg_count);
 		return NULL;
 	}