All of lore.kernel.org
 help / color / mirror / Atom feed
* Eliminating nested functions
@ 2009-04-17 15:54 Pavel Roskin
  2009-04-17 19:33 ` Bean
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Pavel Roskin @ 2009-04-17 15:54 UTC (permalink / raw)
  To: The development of GRUB 2

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



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-04-19 16:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-17 15:54 Eliminating nested functions Pavel Roskin
2009-04-17 19:33 ` Bean
2009-04-17 19:52   ` Vladimir Serbinenko
2009-04-17 21:38   ` Pavel Roskin
2009-04-19  6:38     ` Bean
2009-04-19 14:29       ` Pavel Roskin
2009-04-19 14:51         ` Vladimir Serbinenko
2009-04-19 16:52           ` Bean
2009-04-17 21:57 ` Christian Franke
2009-04-17 23:17 ` David Miller
2009-04-18 15:57   ` Colin D Bennett
2009-04-19  3:52     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.