From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934564AbbEOO64 (ORCPT ); Fri, 15 May 2015 10:58:56 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:40937 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752854AbbEOO6x (ORCPT ); Fri, 15 May 2015 10:58:53 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Nicolas Iooss Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Andrew Morton , linux-kernel@vger.kernel.org, Linux Containers References: <554A0684.2000400@m4x.org> <1431656975-3563-1-git-send-email-nicolas.iooss_linux@m4x.org> <1431656975-3563-2-git-send-email-nicolas.iooss_linux@m4x.org> Date: Fri, 15 May 2015 09:54:04 -0500 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") Message-ID: <877fs9yjqr.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX1846+XDuq/4R7BePfZh1W/tF4kgdKxk3Xs= X-SA-Exim-Connect-IP: 67.3.205.90 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Nicolas Iooss X-Spam-Relay-Country: X-Spam-Timing: total 286 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 3.8 (1.3%), b_tie_ro: 2.7 (1.0%), parse: 0.67 (0.2%), extract_message_metadata: 14 (4.8%), get_uri_detail_list: 1.43 (0.5%), tests_pri_-1000: 8 (2.7%), tests_pri_-950: 1.25 (0.4%), tests_pri_-900: 1.10 (0.4%), tests_pri_-400: 19 (6.5%), check_bayes: 18 (6.2%), b_tokenize: 6 (1.9%), b_tok_get_all: 5 (1.9%), b_comp_prob: 1.50 (0.5%), b_tok_touch_all: 3.0 (1.0%), b_finish: 0.65 (0.2%), tests_pri_0: 233 (81.3%), tests_pri_500: 3.9 (1.4%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH v2 2/2] coredump: add __printf attribute to cn_*printf functions X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nicolas Iooss 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" > > Signed-off-by: Nicolas Iooss > --- > 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': {