Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [obv] Make 'disable_display' static.
Date: Fri, 11 Jan 2013 08:51:00 -0000	[thread overview]
Message-ID: <50EFD269.7000408@codesourcery.com> (raw)
In-Reply-To: <838v80gn16.fsf@gnu.org>

On 01/11/2013 04:08 PM, Eli Zaretskii wrote:
>    . why is it a good idea to go hunting for functions not used outside
>      its source file and make them static?  I don't see this
>      requirement in any coding standards document pertinent to GDB.

During reading the code for other work, I find these functions and 
variables are not used outside of the file, so I am inclined to make 
them static, because it reduces the scope of the functions and variable, 
and accordingly reduces the difficulty on understanding the code (they 
are like non-public functions and can be ignored when figuring out the 
interactions between different modules).

>
>    . if this is NOT mandated by any coding standards we try to enforce,
>      why is this an "obvious" patch?

Of course, there is no coding standard about this.  As you questioned 
this patch, it is not obvious any more.  The "obvious" is interpreted as 
"there is no possibility that anyone will disagree with the change."

>
> The reason I'm asking is that, in general, whoever wrote that function
> could have judged it to be generally useful and export-worthy.  IOW,
> its non-static type might be a result of deliberate design, not a
> historical accident (such as if it was initially static, then made
> extern because some other code, which no longer exists, needed it).
>
> Which one is the case in point, only an investigation into "cvs
> annotate" or "git annotate" can tell.  If such an investigation_was_
> in fact done, it would be a good idea to present it here.
>

disable_display was extern when it was imported into CVS in 1999, but 
not be used out of printcmd.c.  I can't see the reason that original 
author left disable_display extern 14 years ago.

> If it turns out that this function was extern from day one, then we
> should discuss whether it indeed is worthy of being exported, instead
> of defaulting to the "obvious" route based on its current users.

 From time to time, we see patches that remove 'static' of functions, in 
order to get them used else where.  If other files use this function, we 
have to get it exported.  My rationale here is that, it is difficult to 
predict how functions are used in the future, get them 'static' as many 
as we can.

>
> P.S.  This could be judged as bike-shedding, but if the issue is
> serious enough to make a patch, it is serious enough to discuss, IMO.

The issue is not serious.  It is a "side product" when I read and hack 
the source.

-- 
Yao (齐尧)


  reply	other threads:[~2013-01-11  8:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11  2:14 Yao Qi
2013-01-11  8:07 ` Eli Zaretskii
2013-01-11  8:51   ` Yao Qi [this message]
2013-01-11 10:22     ` Eli Zaretskii
2013-01-11 11:32   ` Joel Brobecker
2013-01-11 14:39   ` Tom Tromey
2013-01-11 15:01     ` Pedro Alves
2013-01-11 15:27     ` Gary Benson

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=50EFD269.7000408@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox