From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28131 invoked by alias); 17 Feb 2004 20:28:26 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 28121 invoked from network); 17 Feb 2004 20:28:25 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 17 Feb 2004 20:28:25 -0000 Received: by localhost.redhat.com (Postfix, from userid 469) id A4EFB1A448A; Tue, 17 Feb 2004 15:24:09 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16434.30825.567879.693173@localhost.redhat.com> Date: Tue, 17 Feb 2004 20:28:00 -0000 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com Subject: Re: [ob] Remove initializations of memset'd structure In-Reply-To: <20040217194659.GA32474@nevyn.them.org> References: <20040216211516.GA17055@nevyn.them.org> <16434.9582.574401.561988@localhost.redhat.com> <2914-Tue17Feb2004211147+0200-eliz@elta.co.il> <16434.27783.373959.570693@localhost.redhat.com> <20040217194659.GA32474@nevyn.them.org> X-SW-Source: 2004-02/txt/msg00483.txt.bz2 Daniel Jacobowitz writes: > On Tue, Feb 17, 2004 at 02:33:27PM -0500, Elena Zannoni wrote: > > Eli Zaretskii writes: > > > > From: Elena Zannoni > > > > Date: Tue, 17 Feb 2004 09:30:06 -0500 > > > > > > > > > > > > - MSYMBOL_TYPE (m) = mst_unknown; > > > > > > > > > > This part of the patch seems to assume that mst_unknown has the value > > > > > zero. Should we have such assumptions in the code? > > > > > > > > Yes, in symtab.h mst_unknown is 0. > > > > > > I know that, I looked it up in symtab.h. The question is, should the > > > code rely on the fact that zeroing out the struct causes the > > > MSYMBOL_TYPE member to become mst_unknown. Suppose we change the > > > enumeration some day, that would break the code. > > > > > > > Oh, I see. I misunderstood you. > > > > > So I think a comment is not enough, we should leave that line alone. > > > In general, it is my opinion that code should not assume anything > > > about the numerical values of enumerated types. > > > > That's true. It would be safer to leave the line alone. I'll change > > it back. Also language_unknown is used similarly. > > > > I've committed this. > > Thanks. The only downside is that this suggests the type of the > terminating symbol can ever be read without being in error, which is > incorrect; the minimal symbol table's end appears to be marked by > otherwise by SYMBOL_LINKAGE_NAME (msym) == NULL. Other minimal symbols > may have type mst_unknown. > I am not sure I follow your sentence. If you are worried that the value 0 can indicate a perfectly legal msymbol, this is no different from the situation we end up with when just using the memset. You can always add a new enum value of mst_bogus (pick your name) and use that in the terminating msym. BTW, there is almost identical code in minsyms.c:install_minimal_symbols.