From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2840 invoked by alias); 12 Dec 2001 02:40: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 2704 invoked from network); 12 Dec 2001 02:40:21 -0000 Received: from unknown (HELO localhost.cygnus.com) (205.180.231.71) by sources.redhat.com with SMTP; 12 Dec 2001 02:40:21 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.cygnus.com (Postfix) with ESMTP id 08C473D60; Tue, 11 Dec 2001 18:40:18 -0800 (PST) Message-ID: <3C16C391.9020506@cygnus.com> Date: Tue, 11 Dec 2001 18:40:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:0.9.6) Gecko/20011207 X-Accept-Language: en-us MIME-Version: 1.0 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com Subject: Re: [patch/ob] References: <3C164DDD.5020904@cygnus.com> <20011211144152.A22746@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2001-12/txt/msg00318.txt.bz2 > On Tue, Dec 11, 2001 at 10:18:05AM -0800, Andrew Cagney wrote: > >> Just FYI, >> >> I've checked the attached in as, er, obvious. It fixes a >> -Wuninitialized warning. > > > I agree with the "er, obvious". > > Would there be anything wrong with: > > >> *************** value_fn_field (value_ptr *arg1p, struct >> *** 971,983 **** >> struct minimal_symbol *msym; > > > adding = NULL to the line above? 6 of one, half a dozen of the other. My personal preference is to do an initialization as: if (expr) foo = val1; bar = valb; baz = valz; else if (expr2) foo = val2; bar = valxx; bas = val3; else foo = defaultval; bar = devbar; baz = baxdev; rather than: bar = devbar; baz = baxdev; ... ... ... ... ... ... if (expr) foo = val1; bar = valb; else if (expr2) foo = val2; baz = val3; This is because I consider the former to have clear pre/post assertions and exploits the compiler's -Wuninitialized facility - you know all branches have initialized foo, bar and baz (I'm not sure about the latter example mind :-). This becomes especially useful when handling initialization in in very long switches and if/elif chains. > + gdb_assert (sym == NULL); > > > This assert in particular bugs me. Adding asserts that the compiler > can obviously eliminate, since sym isn't volatile... Here, sorry, I'm lost. Assertions are added to code for many reasons - one being that it helps ``prove'' correctness, another is that it can clarify the intention and assumptions of the developer. I don't think compiler has much to do with this. Keep in mind that we use GCC's -Werror messages as a tool. Not as an end in themselves. enjoy, Andrew