From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751273AbdETLfo (ORCPT ); Sat, 20 May 2017 07:35:44 -0400 Received: from smtprelay0088.hostedemail.com ([216.40.44.88]:56528 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750831AbdETLfm (ORCPT ); Sat, 20 May 2017 07:35:42 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2689:2731:2828:2896:2914:3138:3139:3140:3141:3142:3352:3622:3866:3867:3868:3870:4321:4384:4605:5007:7903:10004:10400:10848:11026:11232:11473:11658:11914:12533:12740:12760:12895:13069:13095:13161:13229:13311:13357:13439:14659:14721:21080:21220:21433:21451:21627:30045:30054:30091,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:error,Custom_rules:0:0:0,LFtime:2000,LUA_SUMMARY:none X-HE-Tag: meal32_13fecf534dd0e X-Filterd-Recvd-Size: 2263 Message-ID: <1495280136.27714.6.camel@perches.com> Subject: Re: [PATCH 1/2] scsi: nsp32: add __printf attribute to logging functions From: Joe Perches To: Nicolas Iooss , GOTO Masanori , YOKOTA Hiroshi Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 20 May 2017 04:35:36 -0700 In-Reply-To: <20170520111628.24787-1-nicolas.iooss_linux@m4x.org> References: <20170520111628.24787-1-nicolas.iooss_linux@m4x.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2017-05-20 at 13:16 +0200, Nicolas Iooss wrote: > 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. [] > diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c [] > @@ -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]; These could also use vsprintf extension %pV instead of vsnprintf to a temporary buffer and then using "%s, " etc... Does anyone actually have or use these cards any longer?