public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* review: xfs_copy fix
@ 2006-10-06  6:18 Timothy Shimmin
  2006-10-06  6:36 ` David Chinner
  0 siblings, 1 reply; 3+ messages in thread
From: Timothy Shimmin @ 2006-10-06  6:18 UTC (permalink / raw)
  To: xfs-dev; +Cc: xfs

Request for review.

xfs_copy was seg faulting for me on my x86_64 box.
This fixes up the variable arg handling for multiple
vfprintf calls by putting va_start and va_end calls
around them (never done this before:).

Thanks,
--Tim


===========================================================================
Index: xfs-cmds/xfsprogs/copy/xfs_copy.c
===================================================================
--- xfs-cmds.orig/xfsprogs/copy/xfs_copy.c	2006-10-06 13:55:01.000000000 
+1000
+++ xfs-cmds/xfsprogs/copy/xfs_copy.c	2006-10-06 13:52:14.000000000 +1000
@@ -77,17 +77,23 @@
 	va_list	ap;
 	int	eek = 0;

-	va_start(ap, fmt);
-	if (flags & LOG)
+	if (flags & LOG) {
+		va_start(ap, fmt);
 		if (vfprintf(logerr, fmt, ap) <= 0)
 			eek = 1;
+		va_end(ap);
+	}
 	if (eek)
 		flags |= ERR;	/* failed, force stderr */
-	if (flags & ERR)
+	if (flags & ERR) {
+		va_start(ap, fmt);
 		vfprintf(stderr, fmt, ap);
-	else if (flags & OUT)
+		va_end(ap);
+	} else if (flags & OUT) {
+		va_start(ap, fmt);
 		vfprintf(stdout, fmt, ap);
-	va_end(ap);
+		va_end(ap);
+	}

 	if (flags & PRE) {
 		do_message(flags & ~PRE, 0, ":  %s\n", strerror(code));

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: review: xfs_copy fix
  2006-10-06  6:18 review: xfs_copy fix Timothy Shimmin
@ 2006-10-06  6:36 ` David Chinner
  2006-10-06  7:15   ` Timothy Shimmin
  0 siblings, 1 reply; 3+ messages in thread
From: David Chinner @ 2006-10-06  6:36 UTC (permalink / raw)
  To: Timothy Shimmin; +Cc: xfs-dev, xfs

On Fri, Oct 06, 2006 at 04:18:10PM +1000, Timothy Shimmin wrote:
> Request for review.
> 
> xfs_copy was seg faulting for me on my x86_64 box.
> This fixes up the variable arg handling for multiple
> vfprintf calls by putting va_start and va_end calls
> around them (never done this before:).

I take it that it was crashing because the LOG flag and one
of ERR or OUT was set so it was trying to do 2 varargs
traversals with only one init?

Looks sane to me.

Cheers,

Dave.
-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: review: xfs_copy fix
  2006-10-06  6:36 ` David Chinner
@ 2006-10-06  7:15   ` Timothy Shimmin
  0 siblings, 0 replies; 3+ messages in thread
From: Timothy Shimmin @ 2006-10-06  7:15 UTC (permalink / raw)
  To: David Chinner; +Cc: xfs-dev, xfs

Hi Dave,

--On 6 October 2006 4:36:43 PM +1000 David Chinner <dgc@sgi.com> wrote:

> On Fri, Oct 06, 2006 at 04:18:10PM +1000, Timothy Shimmin wrote:
>> Request for review.
>>
>> xfs_copy was seg faulting for me on my x86_64 box.
>> This fixes up the variable arg handling for multiple
>> vfprintf calls by putting va_start and va_end calls
>> around them (never done this before:).
>
> I take it that it was crashing because the LOG flag and one
> of ERR or OUT was set so it was trying to do 2 varargs
> traversals with only one init?

Exactly.
In the case I tried, it had LOG and OUT flags on, from memory.

>
> Looks sane to me.
Ta.

--Tim

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-10-06  7:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-06  6:18 review: xfs_copy fix Timothy Shimmin
2006-10-06  6:36 ` David Chinner
2006-10-06  7:15   ` Timothy Shimmin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox