From patchwork Sun Apr 30 21:50:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 9706245 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 9F453602CA for ; Sun, 30 Apr 2017 21:50:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91CFD22B27 for ; Sun, 30 Apr 2017 21:50:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8694225EA6; Sun, 30 Apr 2017 21:50:43 +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 5D17022B27 for ; Sun, 30 Apr 2017 21:50:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1425668AbdD3VuV (ORCPT ); Sun, 30 Apr 2017 17:50:21 -0400 Received: from smtprelay0254.hostedemail.com ([216.40.44.254]:59262 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1424701AbdD3VuT (ORCPT ); Sun, 30 Apr 2017 17:50:19 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id AE91C29DD78; Sun, 30 Apr 2017 21:50:14 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: ball33_1f9dbaa3fc36 X-Filterd-Recvd-Size: 4955 Received: from joe-laptop.perches.com (unknown [47.151.132.55]) (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA; Sun, 30 Apr 2017 21:50:13 +0000 (UTC) From: Joe Perches To: Russell King Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-arm-kernel@lists.infradead.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: fas216: Add __printf validation, fix fallout Date: Sun, 30 Apr 2017 14:50:11 -0700 Message-Id: X-Mailer: git-send-email 2.10.0.rc2.1.g053435c 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 __printf makes the compiler check format and arguments. Fix fallout. Miscellanea: o Convert formats to const char * o Use vsprintf extension %pV instead of a static buffer. o Add newline to logging and remove now unnecessary printk("\n") o Use pr_cont where appropriate Signed-off-by: Joe Perches --- drivers/scsi/arm/fas216.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index 24388795ee9a..112bec886192 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -289,17 +289,20 @@ static char fas216_target(FAS216_Info *info) return 'H'; } -static void -fas216_do_log(FAS216_Info *info, char target, char *fmt, va_list ap) +__printf(3, 0) static void +fas216_do_log(FAS216_Info *info, char target, const char *fmt, va_list ap) { - static char buf[1024]; + struct va_format vaf; + + vaf.fmt = fmt; + vaf.va = ≈ - vsnprintf(buf, sizeof(buf), fmt, ap); - printk("scsi%d.%c: %s", info->host->host_no, target, buf); + printk("scsi%d.%c: %pV\n", info->host->host_no, target, &vaf); } +__printf(4, 5) static void fas216_log_command(FAS216_Info *info, int level, - struct scsi_cmnd *SCpnt, char *fmt, ...) + struct scsi_cmnd *SCpnt, const char *fmt, ...) { va_list args; @@ -313,8 +316,9 @@ static void fas216_log_command(FAS216_Info *info, int level, scsi_print_command(SCpnt); } -static void -fas216_log_target(FAS216_Info *info, int level, int target, char *fmt, ...) +__printf(4, 5) static void +fas216_log_target(FAS216_Info *info, int level, int target, + const char *fmt, ...) { va_list args; @@ -329,11 +333,10 @@ fas216_log_target(FAS216_Info *info, int level, int target, char *fmt, ...) va_start(args, fmt); fas216_do_log(info, target, fmt, args); va_end(args); - - printk("\n"); } -static void fas216_log(FAS216_Info *info, int level, char *fmt, ...) +__printf(3, 4) +static void fas216_log(FAS216_Info *info, int level, const char *fmt, ...) { va_list args; @@ -343,8 +346,6 @@ static void fas216_log(FAS216_Info *info, int level, char *fmt, ...) va_start(args, fmt); fas216_do_log(info, fas216_target(info), fmt, args); va_end(args); - - printk("\n"); } #define PH_SIZE 32 @@ -431,7 +432,7 @@ fas216_get_last_msg(FAS216_Info *info, int pos) } fas216_log(info, LOG_MESSAGES, - "Message: %04x found at position %02x\n", packed_msg, pos); + "Message: %04x found at position %02x", packed_msg, pos); return packed_msg; } @@ -725,7 +726,7 @@ static void fas216_cleanuptransfer(FAS216_Info *info) fifo = fas216_readb(info, REG_CFIS) & CFIS_CF; fas216_log(info, LOG_BUFFER, "cleaning up from previous " - "transfer: length 0x%06x, residual 0x%x, fifo %d", + "transfer: length 0x%06lx, residual 0x%lx, fifo %ld", total, residual, fifo); /* @@ -1144,8 +1145,8 @@ static void fas216_parse_message(FAS216_Info *info, unsigned char *message, int fas216_log(info, 0, "unrecognised message, rejecting"); printk("scsi%d.%c: message was", info->host->host_no, fas216_target(info)); for (i = 0; i < msglen; i++) - printk("%s%02X", i & 31 ? " " : "\n ", message[i]); - printk("\n"); + pr_cont("%s%02X", i & 31 ? " " : "\n ", message[i]); + pr_cont("\n"); /* * Something strange seems to be happening here - @@ -1582,7 +1583,7 @@ static void fas216_funcdone_intr(FAS216_Info *info, unsigned int stat, unsigned default: fas216_log(info, 0, "internal phase %s for function done?" " What do I do with this?", - fas216_target(info), fas216_drv_phase(info)); + fas216_drv_phase(info)); } } @@ -1642,7 +1643,7 @@ irqreturn_t fas216_intr(FAS216_Info *info) fas216_bus_reset(info); scsi_report_bus_reset(info->host, 0); } else if (inst & INST_ILLEGALCMD) { - fas216_log(info, LOG_ERROR, "illegal command given\n"); + fas216_log(info, LOG_ERROR, "illegal command given"); fas216_dumpstate(info); print_debug_list(); } else if (inst & INST_DISCONNECT)