From patchwork Sat May 20 11:16:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Iooss X-Patchwork-Id: 9738559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A7DC6034C for ; Sat, 20 May 2017 11:22:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0C4B28307 for ; Sat, 20 May 2017 11:22:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5A9228622; Sat, 20 May 2017 11:22:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84C3828307 for ; Sat, 20 May 2017 11:22:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751003AbdETLWK (ORCPT ); Sat, 20 May 2017 07:22:10 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:52132 "EHLO mx1.polytechnique.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750940AbdETLWJ (ORCPT ); Sat, 20 May 2017 07:22:09 -0400 Received: from localhost.localdomain (32.206.133.77.rev.sfr.net [77.133.206.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id 3B9405646C8; Sat, 20 May 2017 13:16:46 +0200 (CEST) From: Nicolas Iooss To: GOTO Masanori , YOKOTA Hiroshi Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Iooss Subject: [PATCH 1/2] scsi: nsp32: add __printf attribute to logging functions Date: Sat, 20 May 2017 13:16:27 +0200 Message-Id: <20170520111628.24787-1-nicolas.iooss_linux@m4x.org> X-Mailer: git-send-email 2.12.2 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sat May 20 13:16:46 2017 +0200 (CEST)) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP nsp32_message() and nsp32_dmessage() use printf format strings in order to format a message. Adding __printf attributes helps to detect errors in such format strings at build time, like: drivers/scsi/nsp32.c:3314:23: error: format '%ld' expects argument of type 'long int', but argument 6 has type 'pm_message_t {aka struct pm_message}' [-Werror=format=] nsp32_msg(KERN_INFO, "pci-suspend: pdev=0x%p, state=%ld, slot=%s, host=0x%p", pdev, state, pci_name(pdev), host); Fix all format string errors which were reported by gcc. Signed-off-by: Nicolas Iooss --- drivers/scsi/nsp32.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index 53c84771f0e8..0689b0564fbf 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -257,9 +257,11 @@ static void nsp32_prom_set (nsp32_hw_data *, int, int); static int nsp32_prom_get (nsp32_hw_data *, int); /* debug/warning/info message */ -static void nsp32_message (const char *, int, char *, char *, ...); +static __printf(4, 5) +void nsp32_message (const char *, int, char *, const char *, ...); #ifdef NSP32_DEBUG -static void nsp32_dmessage(const char *, int, int, char *, ...); +static __printf(4, 5) +void nsp32_dmessage(const char *, int, int, const char *, ...); #endif /* @@ -321,7 +323,8 @@ static struct scsi_host_template nsp32_template = { #define NSP32_DEBUG_BUF_LEN 100 -static void nsp32_message(const char *func, int line, char *type, char *fmt, ...) +static __printf(4, 5) +void nsp32_message(const char *func, int line, char *type, const char *fmt, ...) { va_list args; char buf[NSP32_DEBUG_BUF_LEN]; @@ -338,7 +341,8 @@ static void nsp32_message(const char *func, int line, char *type, char *fmt, ... } #ifdef NSP32_DEBUG -static void nsp32_dmessage(const char *func, int line, int mask, char *fmt, ...) +static __printf(4, 5) +void nsp32_dmessage(const char *func, int line, int mask, const char *fmt, ...) { va_list args; char buf[NSP32_DEBUG_BUF_LEN]; @@ -697,7 +701,7 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) nsp32_write1(base, ACK_WIDTH, data->cur_target->ackwidth); nsp32_dbg(NSP32_DEBUG_AUTOSCSI, - "syncreg=0x%x, ackwidth=0x%x, sgtpaddr=0x%x, id=0x%x", + "syncreg=0x%x, ackwidth=0x%x, sgtpaddr=0x%lx, id=0x%x", nsp32_read1(base, SYNC_REG), nsp32_read1(base, ACK_WIDTH), nsp32_read4(base, SGT_ADR), nsp32_read1(base, SCSI_OUT_LATCH_TARGET_ID)); nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "msgout_len=%d, msgout=0x%x", @@ -888,11 +892,11 @@ static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt) if (le32_to_cpu(sgt[i].len) > 0x10000) { nsp32_msg(KERN_ERR, - "can't transfer over 64KB at a time, size=0x%lx", le32_to_cpu(sgt[i].len)); + "can't transfer over 64KB at a time, size=0x%x", le32_to_cpu(sgt[i].len)); return FALSE; } nsp32_dbg(NSP32_DEBUG_SGLIST, - "num 0x%x : addr 0x%lx len 0x%lx", + "num 0x%x : addr 0x%x len 0x%x", i, le32_to_cpu(sgt[i].addr), le32_to_cpu(sgt[i].len )); @@ -915,7 +919,7 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct s nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "enter. target: 0x%x LUN: 0x%llx cmnd: 0x%x cmndlen: 0x%x " - "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x", + "use_sg: 0x%x reqbuf: %p reqlen: 0x%x", SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len, scsi_sg_count(SCpnt), scsi_sglist(SCpnt), scsi_bufflen(SCpnt)); @@ -2742,7 +2746,7 @@ static int nsp32_detect(struct pci_dev *pdev) res = request_region(host->io_port, host->n_io_port, "nsp32"); if (res == NULL) { nsp32_msg(KERN_ERR, - "I/O region 0x%lx+0x%lx is already used", + "I/O region 0x%x+0x%x is already used", data->BaseAddress, data->NumAddress); goto free_irq; } @@ -2853,7 +2857,7 @@ static int nsp32_eh_bus_reset(struct scsi_cmnd *SCpnt) spin_lock_irq(SCpnt->device->host->host_lock); nsp32_msg(KERN_INFO, "Bus Reset"); - nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt); + nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=%p", SCpnt); nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); nsp32_do_bus_reset(data); @@ -2912,7 +2916,7 @@ static int nsp32_eh_host_reset(struct scsi_cmnd *SCpnt) nsp32_hw_data *data = (nsp32_hw_data *)host->hostdata; nsp32_msg(KERN_INFO, "Host Reset"); - nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt); + nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=%p", SCpnt); spin_lock_irq(SCpnt->device->host->host_lock); @@ -3307,7 +3311,7 @@ static int nsp32_suspend(struct pci_dev *pdev, pm_message_t state) { struct Scsi_Host *host = pci_get_drvdata(pdev); - nsp32_msg(KERN_INFO, "pci-suspend: pdev=0x%p, state=%ld, slot=%s, host=0x%p", pdev, state, pci_name(pdev), host); + nsp32_msg(KERN_INFO, "pci-suspend: pdev=0x%p, state=%d, slot=%s, host=0x%p", pdev, state.event, pci_name(pdev), host); pci_save_state (pdev); pci_disable_device (pdev);