All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Nicolas Iooss <nicolas.iooss_linux@m4x.org>,
	GOTO Masanori <gotom@debian.or.jp>,
	YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] scsi: nsp32: add __printf attribute to logging functions
Date: Sat, 20 May 2017 04:35:36 -0700	[thread overview]
Message-ID: <1495280136.27714.6.camel@perches.com> (raw)
In-Reply-To: <20170520111628.24787-1-nicolas.iooss_linux@m4x.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, <tmp>"

etc...

Does anyone actually have or use these cards any longer?

  parent reply	other threads:[~2017-05-20 11:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-20 11:16 [PATCH 1/2] scsi: nsp32: add __printf attribute to logging functions Nicolas Iooss
2017-05-20 11:16 ` [PATCH 2/2] pcmcia: nsp_cs: " Nicolas Iooss
2017-05-20 11:35 ` Joe Perches [this message]
2017-05-24  2:02   ` [PATCH 1/2] scsi: nsp32: " Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1495280136.27714.6.camel@perches.com \
    --to=joe@perches.com \
    --cc=gotom@debian.or.jp \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nicolas.iooss_linux@m4x.org \
    --cc=yokota@netlab.is.tsukuba.ac.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.