From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LuqPD-0003Ef-11 for mharc-grub-devel@gnu.org; Fri, 17 Apr 2009 11:55:07 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LuqPA-0003EL-KS for grub-devel@gnu.org; Fri, 17 Apr 2009 11:55:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LuqP6-0003E0-1D for grub-devel@gnu.org; Fri, 17 Apr 2009 11:55:04 -0400 Received: from [199.232.76.173] (port=49428 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuqP5-0003Dx-Tn for grub-devel@gnu.org; Fri, 17 Apr 2009 11:54:59 -0400 Received: from c60.cesmail.net ([216.154.195.49]:16861) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1LuqP5-0003aX-ED for grub-devel@gnu.org; Fri, 17 Apr 2009 11:54:59 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 17 Apr 2009 11:54:58 -0400 Received: from [192.168.0.22] (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id BDB9A34C6D for ; Fri, 17 Apr 2009 11:56:42 -0400 (EDT) From: Pavel Roskin To: The development of GRUB 2 Content-Type: text/plain Date: Fri, 17 Apr 2009 11:54:57 -0400 Message-Id: <1239983697.4383.15.camel@mj> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 (2.24.5-1.fc10) Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: 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 15:55:04 -0000 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. The 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. We 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(). It 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