All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Eliminating nested functions
Date: Fri, 17 Apr 2009 11:54:57 -0400	[thread overview]
Message-ID: <1239983697.4383.15.camel@mj> (raw)

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



             reply	other threads:[~2009-04-17 15:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-17 15:54 Pavel Roskin [this message]
2009-04-17 19:33 ` Eliminating nested functions 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1239983697.4383.15.camel@mj \
    --to=proski@gnu.org \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.