Re: [PATCH 1/2] do_wait reorganization

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Saturday, March 29, 2008 - 9:16 am

On Fri, 28 Mar 2008, Roland McGrath wrote:

How about a further non-obviousness?

...
...

I think it would be even more obvious (or, to use your phrase, "less 
nonobvious") if this was written like so:

	if (task_is_stopped_or_traced(p)) {
		...
		....
			if (*retval}
				return 1;
		}
		return 0;
	}

	if (p->exit_state == EXIT_ZOMBIE && !delay_group_leader(p)) {
		...
		return 0;
	}

	if (...)

because then you can clearly see that smething like the
"task_is_stopped_or_traced(p)" case is complete in itself, and only has 
its own local stuff going on.

(And at some point I'd also almost make each case a trivial small inline 
function of its on, but in this case there are so many arguments to pass 
around that it probably becomes _less_ readable that way).

I also wonder if you really need both "int *retval" and the return value. 
Isn't "retval" always going to be zero or a negative errno? And the return 
value is going to be either true of false? Why not just fold them into one 
single thing:

 - negative: all done, with error
 - zero: this didn't trigger, continue with the next one in caller
 - positive: this thread triggered, all done, return 0 in the caller.

which is (I think) close to what we already do in eligible_child() (so 
this would not be a new calling convention for this particular code).

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

Messages in current thread:
[PATCH 1/2] do_wait reorganization, Roland McGrath, (Fri Mar 28, 8:34 pm)
[PATCH 2/2] ptrace children revamp, Roland McGrath, (Fri Mar 28, 8:35 pm)
Re: [PATCH 1/2] do_wait reorganization, Oleg Nesterov, (Sat Mar 29, 3:35 am)
Re: [PATCH 2/2] ptrace children revamp, Oleg Nesterov, (Sat Mar 29, 3:39 am)
Re: [PATCH 2/2] ptrace children revamp, Oleg Nesterov, (Sat Mar 29, 6:10 am)
Re: [PATCH 2/2] ptrace children revamp, Oleg Nesterov, (Sat Mar 29, 7:37 am)
Re: [PATCH 1/2] do_wait reorganization, Linus Torvalds, (Sat Mar 29, 9:16 am)
Re: [PATCH 1/2] do_wait reorganization, Roland McGrath, (Sun Mar 30, 8:27 pm)
Re: [PATCH 1/2] do_wait reorganization, Roland McGrath, (Sun Mar 30, 8:54 pm)
[PATCH 1/3] do_wait reorganization, Roland McGrath, (Sun Mar 30, 8:57 pm)
[PATCH 2/3] ptrace children revamp, Roland McGrath, (Sun Mar 30, 8:59 pm)
Re: [PATCH 1/3] do_wait reorganization, Oleg Nesterov, (Mon Mar 31, 1:51 am)
Re: [PATCH 2/3] ptrace children revamp, Oleg Nesterov, (Mon Mar 31, 2:12 am)
Re: [PATCH 1/3] do_wait reorganization, Oleg Nesterov, (Mon Mar 31, 1:07 pm)
Re: [PATCH 1/3] do_wait reorganization, Roland McGrath, (Mon Mar 31, 1:29 pm)
Re: [PATCH 2/2] ptrace children revamp, Roland McGrath, (Fri Apr 4, 2:00 pm)
Re: [PATCH 2/2] ptrace children revamp, Oleg Nesterov, (Sat Apr 5, 7:06 am)
Re: [PATCH 2/2] ptrace children revamp, Roland McGrath, (Wed Apr 9, 1:15 pm)
Re: [PATCH 2/2] ptrace children revamp, Oleg Nesterov, (Sun Apr 13, 7:24 am)
Re: [PATCH 2/2] ptrace children revamp, Roland McGrath, (Mon Apr 14, 6:41 pm)