From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lutp6-0005jV-PD for mharc-grub-devel@gnu.org; Fri, 17 Apr 2009 15:34:04 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lutp5-0005j3-Gz for grub-devel@gnu.org; Fri, 17 Apr 2009 15:34:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lutp2-0005bT-2T for grub-devel@gnu.org; Fri, 17 Apr 2009 15:34:03 -0400 Received: from [199.232.76.173] (port=58468 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lutp1-0005bI-RF for grub-devel@gnu.org; Fri, 17 Apr 2009 15:33:59 -0400 Received: from ti-out-0910.google.com ([209.85.142.189]:30343) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lutp0-0005Ix-Lk for grub-devel@gnu.org; Fri, 17 Apr 2009 15:33:58 -0400 Received: by ti-out-0910.google.com with SMTP id b6so627510tic.10 for ; Fri, 17 Apr 2009 12:33:56 -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=EZUyRgotll0997PCSeMZvfcDXMiHrffA5Wix3Kl/UYQ=; b=itANk/0ZAW4meq3K3whf7UGH7jxyCuClRKnMFP4DYiVYE5CT03w6Hy5LtQOcWrFom7 QBuuQT1pJX4yE/AjbdVr26ySrWDCDdXkaMhqNUuCzk7UMO1czI7GM7M8BudAYJ7BbZOv ICIMODuPPXU2KaqxJYxe7B94W3cpbdfZku7qw= 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=WU+CLSqix+joDB0NqZBnijtX9Mz8uLZTpfbk3/m+zpjCPwoYphlSJM94HK3waMCbC+ +xyCP97uCcxbtGjl1CKHXA0CP+GPhF3Q8H2s47ZO6KGqVsAwMM5Hh8ak77PuxndXL7w6 rhnMdU04U4OXslbzHRCgDOJKUCWc4I5FzBJdo= MIME-Version: 1.0 Received: by 10.110.95.3 with SMTP id s3mr3192070tib.13.1239996836597; Fri, 17 Apr 2009 12:33:56 -0700 (PDT) In-Reply-To: <1239983697.4383.15.camel@mj> References: <1239983697.4383.15.camel@mj> Date: Sat, 18 Apr 2009 03:33:56 +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: Fri, 17 Apr 2009 19:34:03 -0000 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. On Fri, Apr 17, 2009 at 11:54 PM, Pavel Roskin wrote: > Hello! > > While I have just applied a patch adding NESTED_FUNC_ATTR to several > functions as an emergency fix for a major breakage in ata, ohci, uhci > and lspci modules, I would prefer a more radical solution. > > I suggest that we eliminate all nested functions. =A0The reasons are: > > 1) They make the code less readable, as they make the parent functions > longer. > > 2) They have problems with some popular compilers, as recent as gcc-4.0 > when regparm(3) is used. > > 3) We failed to implement a reliable test for such problems. =A0We are > using regparm(1) for all compilers. > > 4) The existing test is one of the obstacles making it impossible to > compile without having libc for the target (x86_64->i386 would be really > nice), as we need to run the compiled test executable. > > 5) Non-i386 architectures define NESTED_FUNC_ATTR as an empty symbol, so > developers on such architectures don't see if they use it correctly. > > 6) NESTED_FUNC_ATTR tends to proliferate to the file scope functions, as > it happened with grub_pci_iterate(). =A0It only takes one caller using a > nested function to force NESTED_FUNC_ATTR on all functions used as an > argument to the same function. > > We can give all formerly nested functions better, more descriptive names > starting like other functions in the file and ending with "_iter". > > -- > Regards, > Pavel Roskin > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > --=20 Bean