Re: [PATCH 1/2] Massive code cleanup of sys_msync()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Randy Dunlap <randy.dunlap@...>
Cc: Anton Salikhmetov <salikhmetov@...>, Christoph Hellwig <hch@...>, <linux-mm@...>, <jakob@...>, <linux-kernel@...>, <valdis.kletnieks@...>, <riel@...>, <ksm@...>, <staubach@...>, <jesper.juhl@...>, <torvalds@...>, <a.p.zijlstra@...>, <akpm@...>, <protasnb@...>, <miklos@...>
Date: Tuesday, January 15, 2008 - 4:46 pm

On Tue, 2008-01-15 at 11:10 -0800, Randy Dunlap wrote:

When we're not cleaning up resources, the main advantage of having a
single point of return is that you can trace backwards from the return
point through the function's logic. But that advantage flies right out
the window when you use gotos. You still have to figure out how you got
to the return statement by tracing back and looking at all the possible
gotos. And the "goto out" style adds bulk and non-negligible complexity
when we've got to search back for what the last explicitly set value of
"ret" or "error" or whatever the function in question is using was.
Sometimes people get this wrong ("retval is already -EINVAL, so I don't
need to explicitly set it"), and create bugs.

So I think if we're not actually going to use "structured
programming" (no gotos) or "stack cleanup" styles, the single return
point style is more trouble than it's worth.

A lesser advantage of the single return point is that you can set a
breakpoint or put a printk at the end of a function. But I don't think
that's much justification.

-- 
Mathematics is the supreme nostalgia of our time.

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/2] Updating ctime and mtime for memory-mapped files..., Anton Salikhmetov, (Tue Jan 15, 12:02 pm)
Re: [PATCH 0/2] Updating ctime and mtime for memory-mapped f..., Anton Salikhmetov, (Tue Jan 15, 6:15 pm)
[PATCH 1/2] Massive code cleanup of sys_msync(), Anton Salikhmetov, (Tue Jan 15, 12:02 pm)
Re: [PATCH 1/2] Massive code cleanup of sys_msync(), Christoph Hellwig, (Tue Jan 15, 1:57 pm)
Re: [PATCH 1/2] Massive code cleanup of sys_msync(), Anton Salikhmetov, (Tue Jan 15, 3:02 pm)
Re: [PATCH 1/2] Massive code cleanup of sys_msync(), Randy Dunlap, (Tue Jan 15, 3:10 pm)
Re: [PATCH 1/2] Massive code cleanup of sys_msync(), Matt Mackall, (Tue Jan 15, 4:46 pm)
Re: [PATCH 1/2] Massive code cleanup of sys_msync(), Randy Dunlap, (Tue Jan 15, 5:06 pm)
Re: [PATCH 1/2] Massive code cleanup of sys_msync(), Anton Salikhmetov, (Tue Jan 15, 3:26 pm)
Re: [PATCH 1/2] Massive code cleanup of sys_msync(), Peter Zijlstra, (Tue Jan 15, 3:28 pm)
Re: [PATCH 1/2] Massive code cleanup of sys_msync(), Christoph Hellwig, (Tue Jan 15, 3:32 pm)
Re: [PATCH 1/2] Massive code cleanup of sys_msync(), Anton Salikhmetov, (Tue Jan 15, 4:12 pm)
[PATCH 2/2] Updating ctime and mtime at syncing, Anton Salikhmetov, (Tue Jan 15, 12:02 pm)
Re: [PATCH 2/2] Updating ctime and mtime at syncing, Christoph Hellwig, (Tue Jan 15, 2:04 pm)
Re: [PATCH 2/2] Updating ctime and mtime at syncing, Anton Salikhmetov, (Tue Jan 15, 3:04 pm)
Re: [PATCH 2/2] Updating ctime and mtime at syncing, Peter Zijlstra, (Tue Jan 15, 12:35 pm)
Re: [PATCH 2/2] Updating ctime and mtime at syncing, Anton Salikhmetov, (Tue Jan 15, 1:18 pm)
Re: [PATCH 2/2] Updating ctime and mtime at syncing, Peter Zijlstra, (Tue Jan 15, 3:30 pm)