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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 );



_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs


[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux