grub-devel
[Top][All Lists]
Advanced

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

Re: Eliminating nested functions


From: Bean
Subject: Re: Eliminating nested functions
Date: Sun, 19 Apr 2009 14:38:20 +0800

Hi,

Yeah, I agree with you. The conversion will take some effort, but it
could payoff in the long run. Perhaps we can achieve this in two
steps:

1, Change nested function definition to accept only one parameter. For
function with multiple parameters, place them in a structure and pass
the pointer. This would eliminate NESTED_FUNC_ATTR, as the regparm
issue won't occur in function with only one parameter.

2. Eliminate nested function. This would be easier after step 1. As we
now pass parameters in a structure, we can append extra variables at
the end, and cast it to the required type. Inside the callback
function, we cast it back to use the extra fields.

On Sat, Apr 18, 2009 at 5:38 AM, Pavel Roskin <address@hidden> wrote:
> On Sat, 2009-04-18 at 03:33 +0800, Bean wrote:
>> Hi,
>>
>> One of the advantage of nested function is to use local variables.
>> Without it, we would need to pass them as global variable, or add
>> custom data pointer in many of the iterate function, which would make
>> the code a lot uglier IMO.
>
> Indeed, I tried to get rid on nested functions in fs/ext2.c, and it
> requires more changes than I expected.
>
> However, my impression is that everything can be written nicely with
> more effort.  Some arguments could be put into the structures we need to
> pass, so the number of arguments doesn't increase.
>
> We should probably try to avoid adding new nested functions in the
> meantime.
>
> --
> Regards,
> Pavel Roskin
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Bean




reply via email to

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