From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LvQfg-00089u-H8 for mharc-grub-devel@gnu.org; Sun, 19 Apr 2009 02:38:32 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LvQfe-00089p-Sn for grub-devel@gnu.org; Sun, 19 Apr 2009 02:38:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LvQfZ-00085R-8P for grub-devel@gnu.org; Sun, 19 Apr 2009 02:38:29 -0400 Received: from [199.232.76.173] (port=47303 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LvQfZ-00085J-2Q for grub-devel@gnu.org; Sun, 19 Apr 2009 02:38:25 -0400 Received: from ti-out-0910.google.com ([209.85.142.187]:62127) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LvQfY-0005QD-Bx for grub-devel@gnu.org; Sun, 19 Apr 2009 02:38:24 -0400 Received: by ti-out-0910.google.com with SMTP id b6so920593tic.10 for ; Sat, 18 Apr 2009 23:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=WHGcJqC2/BISNHrVwb6SseBbMEFCoQAaDObrbdcNga0=; b=Cz7OVC1BC9cA0Xd4vGfMM3/fQLBNGy/2EHljFLUBihKptenkNYXmNQDoSsiP/XHP4F 16ujn02blEhXhPWN0iccSiD8AUN+WHjMlOHFY8ZeXUci/GxYqI9nw4gHxGsZADRh0vwL neu9I+r98ohxboFLuFaT4GjU4TgVu21s4ZxwI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=tRKpEqZYj6qzlcCAiDnIcPqzdG3UBVRTTckRYok3/YcIJQn+TztwNeTrMY32bNEE3P LS8yMKZ9uj+CkbrBiSLoHifZw5avM81eSqzYEIIYji6W+DPxkcXSv1sQaO4AAi27uurB CkwRySUxsKMZMj5b6lFajKFpj/YmYTzRPYw6M= MIME-Version: 1.0 Received: by 10.110.28.15 with SMTP id b15mr4848030tib.4.1240123100228; Sat, 18 Apr 2009 23:38:20 -0700 (PDT) In-Reply-To: <1240004288.9057.5.camel@mj> References: <1239983697.4383.15.camel@mj> <1240004288.9057.5.camel@mj> Date: Sun, 19 Apr 2009 14:38:20 +0800 Message-ID: From: Bean To: The development of GRUB 2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: Eliminating nested functions X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Apr 2009 06:38:31 -0000 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 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. =A0Some arguments could be put into the structures we need t= o > 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 > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > --=20 Bean