From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6243 invoked by alias); 20 Oct 2005 08:43:09 -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 6235 invoked by uid 22791); 20 Oct 2005 08:43:06 -0000 Received: from nitzan.inter.net.il (HELO nitzan.inter.net.il) (192.114.186.20) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 20 Oct 2005 08:43:06 +0000 Received: from HOME-C4E4A596F7 (IGLD-80-230-148-220.inter.net.il [80.230.148.220]) by nitzan.inter.net.il (MOS 3.6.5-GR) with ESMTP id BSY35465 (AUTH halo1); Thu, 20 Oct 2005 10:43:00 +0200 (IST) Date: Thu, 20 Oct 2005 08:43:00 -0000 Message-Id: From: Eli Zaretskii To: Andrew STUBBS CC: gdb-patches@sources.redhat.com In-reply-to: <20051019200751.GA19037@nevyn.them.org> (message from Daniel Jacobowitz on Wed, 19 Oct 2005 16:07:51 -0400) Subject: Re: PATCH: Problem union comparision in TUI Reply-to: Eli Zaretskii References: <4353BA69.1030401@st.com> <43561685.3010300@st.com> <20051019200751.GA19037@nevyn.them.org> X-SW-Source: 2005-10/txt/msg00166.txt.bz2 > Date: Wed, 19 Oct 2005 16:07:51 -0400 > From: Daniel Jacobowitz > Cc: Andrew STUBBS , gdb-patches@sources.redhat.com > > > The reason is that the code should be clean and self-explanatory. > > Using the same variable for storing two utterly different objects is > > IMHO The Mother Of Unclean Code. > > Is an untagged union any clearer? No, it isn't. I suggested to modify the data structure so that the union is tagged. Did you see that message? > We've already established (via the bug report) that some of the time, > the code has no idea which one is in use when comparing them. They're > used for relative line ordering within a particular window; if it's a > source window, the lines are sorted by line number, and if it's a > disassembly window, they're sorted by code address. So in both cases > it's a "line number"; that's why I favor using a single variable for > them, although I'm open to alternative suggestions. Yes, I've read the code before I replied, so I know all that already. Having read the code, I'm not sure that addresses are used only for disassembly windows and line numbers only for source windows. We could have more bugs; that's why I think cleaning the code is important. I think it shouldn't be too hard to make the change I suggested, since most of it boils down to mechanically adding either the line or address tag whenever the respective member of the union is assigned a value.