From patchwork Sun Jan 8 20:13:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 40559 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1837399wrt; Sun, 8 Jan 2023 12:14:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXsbq90j0CGxMrU5ysDziSLdTKIJZAxmDTW/3IeB/fY770dVS7B4tgTPmz/AZ3GNtYGr6V15 X-Received: by 2002:a05:6402:c91:b0:498:dec8:f41e with SMTP id cm17-20020a0564020c9100b00498dec8f41emr4105173edb.3.1673208891747; Sun, 08 Jan 2023 12:14:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673208891; cv=none; d=google.com; s=arc-20160816; b=f3LVcYNZRD6oByCi54Qnn2+24ePQyYo9RxpfvTKRwXHgMBWhIVx13JqYnMO9YGDODH S7d0HrIueYeyv5jzxPb4ktoYxfq29/PulxKgcjDVhH3Y9zJLD+WhZpjZc9guVVoeguir pAd2jM/uNCTMgqvQBwW+mMi8Z087e7Lv/H2/L8dvHoTGBJeUf+QMRaDu/nhXnFnCeocN fMmDMcnzLFLptHTfiSNTF+h3G0KczmFbW7fVNSrNoKdJQ87Sg/JHYUnlgLjXB/SOmYnt ZgsBIlmvo7ixj3tXVZk7GkFVB4CUFAxXS4LerIb+fcT2r45Tacs83iHcG0S4dLWspv9x Wi2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=AZZkBtfdJVI2RyjOOEH507lyT5L36PPH+suE5zYAHlQ=; b=RoK7hene4LTZfc2MigX7+2ABlGN2jyaBoY33CbTrUX7ui/H713c81wkgYFfR87Vp1p zVrRC3Z8sYiBt3hoHbCsesJGKnZRrfysO29h4yapqxuQEN8DrWr4gp8Mwk9fuZJMPWaJ U98lm/c6PsMoZoxwbS3ch8HZwf0YeQkoh017nZPPlVTMtMuDwuNaS16dLx2eNrJIVRwK b9DHT95r+WalgGRGnZOw6R1OoI6DlwDk9rrK1UBoQPHTbX7L/gzqTZ2cAVpzDuG9tHGk WN4pwuWRMx3x4Ho9eVqCTNwU23qDVf26yw/ScdM2BPuKUtbU5yqGIyHL3bfPtII3O13I WFSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=dRTEpHbs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d14-20020a056402400e00b0046af62544a0si7969862eda.401.2023.01.08.12.14.27; Sun, 08 Jan 2023 12:14:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=dRTEpHbs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233826AbjAHUNl (ORCPT + 99 others); Sun, 8 Jan 2023 15:13:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236101AbjAHUNa (ORCPT ); Sun, 8 Jan 2023 15:13:30 -0500 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D6BD2671; Sun, 8 Jan 2023 12:13:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1673208800; bh=KK4gdVcPkbx53T8nteORF7wE5stV6jTMnhmIKRwioCA=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=dRTEpHbsiYQnW5JX9HHf9oPr/RwLZMwAjIML/ixJCvuIvGypC9YkeQHaLFlB7S3L8 ZB1FdlF/qZBaXWT/RP9Eu7U533mC3H10H0gU7/8UbmFmM09tAAmZagLElGobhM4Gyy kzmuQtpvvG9wlXxddJ2dGC8llZqZwAFGby635P6U= Received: by b-3.in.mailobj.net [192.168.90.13] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sun, 8 Jan 2023 21:13:20 +0100 (CET) X-EA-Auth: QzJkpgvuklnVpan+KktYI8NBrX6wZ9giHA77fbQ68+m9op63iHv+LC14cxn1CgsqZjmbUJuY99opuOT3wCTFk/NNnuhjtTP9 Date: Mon, 9 Jan 2023 01:43:15 +0530 From: Deepak R Varma To: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar Subject: [PATCH v2] scsi: Replace printk+WARN_ON by WARN macro Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754482886434193402?= X-GMAIL-MSGID: =?utf-8?q?1754486686660630989?= 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 --- 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(-) 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; }