grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] export -boot parameter as qemu_boot{0,1,2}


From: Pavel Roskin
Subject: Re: [PATCH] export -boot parameter as qemu_boot{0,1,2}
Date: Mon, 29 Jun 2009 18:59:22 -0400

On Mon, 2009-06-29 at 15:49 +0200, Robert Millan wrote:

> > Use of a nested function seems totally unwarranted.
> 
> I did it to make the code more readable.  Declaring functions that will
> be used locally inside their scope improves code clarity and prevents
> mistakes (like attempting to run them from somewhere else).

However, they are not widely used.  In GRUB, nested functions are used
to allow passing them as callbacks that can access local variables of
the containing function.

There is a problem associates with nested functions.  Some versions of
gcc miscompile them with -mregparm=3.  Arguments other than the first
one are not passed correctly.  There was a test in configure.ac, but it
turned out to be wrong, so we are always specifying
__attribute__((__regparm__(1))) for nested functions taking more than
one argument on i386 (kernel code only).

Just look for NESTED_FUNC_ATTR to see what I mean.  We had several bugs
because NESTED_FUNC_ATTR wasn't used consistently.

I don't know if NESTED_FUNC_ATTR is needed in your case, or it's only
needed when the function is passed as an argument.  In any case, I think
it's an overkill for the problem you are solving.

> > We actually agreed
> > a while ago that they are bad, but nobody had time to remove them.
> 
> I didn't participate in that discussion.  Did Marco and Okuji agree with this?

They didn't participate.

-- 
Regards,
Pavel Roskin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]