From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.124] helo=mx.sourceforge.net) by 335xhf1.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Mgueg-0004V4-M7 for Ltp-list@lists.sourceforge.net; Fri, 28 Aug 2009 06:09:46 +0000 Received: from e32.co.us.ibm.com ([32.97.110.150]) by 1b2kzd1.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1MgueZ-0001Gy-2f for Ltp-list@lists.sourceforge.net; Fri, 28 Aug 2009 06:09:46 +0000 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e32.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id n7S64pQV010259 for ; Fri, 28 Aug 2009 00:04:51 -0600 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n7S69Tdo064452 for ; Fri, 28 Aug 2009 00:09:29 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n7S69TEY013260 for ; Fri, 28 Aug 2009 00:09:29 -0600 From: Subrata Modak In-Reply-To: References: Date: Fri, 28 Aug 2009 11:38:55 +0530 Message-Id: <1251439738.9081.9.camel@subratamodak.linux.ibm.com> Mime-Version: 1.0 Subject: Re: [LTP] [PATCH] Annotate tst_*() helpers with __attribute__ ((format (printf, M, N))) (was: Re: [PATCH] quotactl01: Fix tst_resm() format causing crash) Reply-To: subrata@linux.vnet.ibm.com List-Id: Linux Test Project General Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-list-bounces@lists.sourceforge.net To: Geert Uytterhoeven Cc: Linux Test Project On Thu, 2009-08-27 at 17:29 +0200, Geert Uytterhoeven wrote: > On Thu, 27 Aug 2009, Geert Uytterhoeven wrote: > > When the quotactl syscall fails, quotactl01 crashes with a segmentation fault > > due to an incorrect printf()-style format. > > This bug encouraged me to add annotations to the test helpers that take > printf()-style formats, cfr. the patch below. > > It causes a massive amount of compiler warnings, most of them caused by > TEST_ERRNO being long. According to CVS history, both TEST_RETURN and > TEST_ERRNO have been changed from int to long to accomodate 64-bit platforms, > but to me the change of TEST_ERRNO looks bogus. > As errno is int according to C99, TEST_ERRNO should actually be int too, right? > > Note that there are also a few other cases where integers are used on pointer > type format specifiers. These will cause crashes when the code path is > executed. > > >From 601578f79c05779acefe023fd499726d9fe4ce03 Mon Sep 17 00:00:00 2001 > From: Geert Uytterhoeven > Date: Thu, 27 Aug 2009 17:08:18 +0200 > Subject: [PATCH] Annotate tst_*() helpers with __attribute__ ((format (printf, M, N))) > > Signed-off-by: Geert Uytterhoeven Ok. Thanks. Regards-- Subrata > --- > include/test.h | 18 ++++++++++++------ > 1 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/include/test.h b/include/test.h > index 34ed5d2..03b0d46 100644 > --- a/include/test.h > +++ b/include/test.h > @@ -186,12 +186,18 @@ > * Functions from lib/tst_res.c > */ > const char *strttype(int ttype); > -void tst_res(int ttype, char *fname, char *arg_fmt, ...); > -void tst_resm(int ttype, char *arg_fmt, ...); > -void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...); > -void tst_brkloop(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...); > -void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...); > -void tst_brkloopm(int ttype, void (*func)(void), char *arg_fmt, ...); > +void tst_res(int ttype, char *fname, char *arg_fmt, ...) > + __attribute__ ((format (printf, 3, 4))); > +void tst_resm(int ttype, char *arg_fmt, ...) > + __attribute__ ((format (printf, 2, 3))); > +void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...) > + __attribute__ ((format (printf, 4, 5))); > +void tst_brkloop(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...) > + __attribute__ ((format (printf, 4, 5))); > +void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...) > + __attribute__ ((format (printf, 3, 4))); > +void tst_brkloopm(int ttype, void (*func)(void), char *arg_fmt, ...) > + __attribute__ ((format (printf, 3, 4))); > void tst_require_root(void (*func)(void)); > int tst_environ(void); > void tst_exit(void) LTP_ATTRIBUTE_NORETURN; ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list