From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29417 invoked by alias); 11 Jan 2013 08:51:20 -0000 Received: (qmail 29408 invoked by uid 22791); 11 Jan 2013 08:51:19 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Jan 2013 08:51:16 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1TtaKZ-0003Kl-8O from Yao_Qi@mentor.com ; Fri, 11 Jan 2013 00:51:15 -0800 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 11 Jan 2013 00:51:14 -0800 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Fri, 11 Jan 2013 00:51:14 -0800 Message-ID: <50EFD269.7000408@codesourcery.com> Date: Fri, 11 Jan 2013 08:51:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Eli Zaretskii CC: Subject: Re: [obv] Make 'disable_display' static. References: <1357870430-19757-1-git-send-email-yao@codesourcery.com> <838v80gn16.fsf@gnu.org> In-Reply-To: <838v80gn16.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00214.txt.bz2 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 (齐尧)