From: ebiederm@xmission.com (Eric W. Biederman)
To: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Linux Containers <containers@lists.linux-foundation.org>
Subject: Re: [PATCH v2 2/2] coredump: add __printf attribute to cn_*printf functions
Date: Fri, 15 May 2015 09:54:04 -0500 [thread overview]
Message-ID: <877fs9yjqr.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <1431656975-3563-2-git-send-email-nicolas.iooss_linux@m4x.org> (Nicolas Iooss's message of "Fri, 15 May 2015 10:29:35 +0800")
Nicolas Iooss <nicolas.iooss_linux@m4x.org> writes:
> This allows detecting improper format string at build time, like:
>
> fs/coredump.c:225:5: warning: format '%ld' expects argument of type
> 'long int', but argument 3 has type 'int' [-Wformat=]
> err = cn_printf(cn, "%ld", cprm->siginfo->si_signo);
> ^
>
> As si_signo is always an int, the format should be %d here.
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
> ---
> fs/coredump.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/fs/coredump.c b/fs/coredump.c
> index 833a57bc856c..e52e0064feac 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -70,7 +70,8 @@ static int expand_corename(struct core_name *cn, int size)
> return 0;
> }
>
> -static int cn_vprintf(struct core_name *cn, const char *fmt, va_list arg)
> +static __printf(2, 0) int cn_vprintf(struct core_name *cn, const char *fmt,
> + va_list arg)
> {
> int free, need;
> va_list arg_copy;
> @@ -93,7 +94,7 @@ again:
> return -ENOMEM;
> }
>
> -static int cn_printf(struct core_name *cn, const char *fmt, ...)
> +static __printf(2, 3) int cn_printf(struct core_name *cn, const char *fmt, ...)
> {
> va_list arg;
> int ret;
> @@ -105,7 +106,8 @@ static int cn_printf(struct core_name *cn, const char *fmt, ...)
> return ret;
> }
>
> -static int cn_esc_printf(struct core_name *cn, const char *fmt, ...)
> +static __printf(2, 3)
> +int cn_esc_printf(struct core_name *cn, const char *fmt, ...)
> {
> int cur = cn->used;
> va_list arg;
> @@ -225,7 +227,8 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
> break;
> /* signal that caused the coredump */
> case 's':
> - err = cn_printf(cn, "%ld", cprm->siginfo->si_signo);
> + err = cn_printf(cn, "%d",
> + cprm->siginfo->si_signo);
> break;
> /* UNIX time of coredump */
> case 't': {
next prev parent reply other threads:[~2015-05-15 14:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-16 10:28 [PATCH RESENT] coredump: fix cn_printf formatting warnings Nicolas Iooss
2015-04-16 10:50 ` Joe Perches
2015-05-03 10:34 ` [PATCH 1/2] coredump: use from_kuid/kgid_munged when formatting corename Nicolas Iooss
2015-05-03 10:34 ` [PATCH 2/2] coredump: add __printf attribute to cn_*printf functions Nicolas Iooss
2015-05-05 19:13 ` [PATCH 1/2] coredump: use from_kuid/kgid_munged when formatting corename Eric W. Biederman
2015-05-06 12:18 ` Nicolas Iooss
2015-05-15 2:29 ` [PATCH v2 1/2] coredump: use from_kuid/kgid " Nicolas Iooss
2015-05-15 2:29 ` [PATCH v2 2/2] coredump: add __printf attribute to cn_*printf functions Nicolas Iooss
2015-05-15 14:54 ` Eric W. Biederman [this message]
2015-05-15 14:52 ` [PATCH v2 1/2] coredump: use from_kuid/kgid when formatting corename Eric W. Biederman
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=877fs9yjqr.fsf@x220.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.iooss_linux@m4x.org \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®