xfs
[Top] [All Lists]

Re: [PATCH] xfsdump: fill in missing strerror() call

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH] xfsdump: fill in missing strerror() call
From: Alex Elder <elder@xxxxxxxxxxx>
Date: Thu, 27 Dec 2012 08:33:10 -0600
Cc: xfs@xxxxxxxxxxx
In-reply-to: <20121227074410.GA13234@xxxxxxxxxxxxx>
References: <50D7A1C2.9000609@xxxxxxxxxxxxxxx> <50DB794F.7010906@xxxxxxxxxxx> <20121227074410.GA13234@xxxxxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0
On 12/27/2012 01:44 AM, Christoph Hellwig wrote:
> On Wed, Dec 26, 2012 at 04:25:19PM -0600, Alex Elder wrote:
>> Nigel Tamplin reported getting a seg fault in xfsrestore when a path
>> name was too long.
>>
>> Based on the surrounding code, I'm sure strerror(errno) was the
>> intended final argument to this call.  This bug has been there
>> since the code was first committed.
> 
> Seems like mlog needs an attribute marking it as printf-like.  
> I'll see if I can come up with a patch for that.
> 

That patch is easy.  Fixing all the problems that points out
leads to something quite a bit bigger.  I started on it but
have put it aside for now.  In case anyone wants to take on
that challenge I've included the patch for activating the
warnings below.

                                        -Alex

[PATCH] xfsdump: annotate mlog() as printf-like

The mlog() function is basically a printf() wrapper.  Take advantage
of the gcc extension that will verify compatibility between the
format argument and the arguments that follow.

Define a __printf() macro like Linux does so the declaration line
doesn't get too long.

Signed-off-by: Alex Elder <elder@xxxxxxxxxxx>
---
 common/mlog.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: b/common/mlog.h
===================================================================
--- a/common/mlog.h
+++ b/common/mlog.h
@@ -109,7 +109,8 @@ void mlog_override_level( intgen_t level

 /* vprintf-based message format
  */
-extern void mlog( intgen_t level, char *fmt, ... );
+#define __printf(a, b) __attribute__((format(printf, a, b)))
+extern void __printf(2, 3) mlog( intgen_t level, char *fmt, ... );
 extern void mlog_va( intgen_t levelarg, char *fmt, va_list args );
 #define mlog_exit( e, r ) _mlog_exit( __FILE__, __LINE__, (e), (r) )
 extern int  _mlog_exit( const char *file, int line, int exit_code, rv_t
return_code );



<Prev in Thread] Current Thread [Next in Thread>