From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10337 invoked by alias); 16 Jan 2014 16:38:17 -0000 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 Received: (qmail 10301 invoked by uid 89); 16 Jan 2014 16:38:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Jan 2014 16:38:15 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0GGcC0B019069 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 16 Jan 2014 11:38:12 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0GGcAjK012223; Thu, 16 Jan 2014 11:38:11 -0500 Message-ID: <52D80AF2.5010605@redhat.com> Date: Thu, 16 Jan 2014 16:38:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Simon Marchi CC: GDB Patches Subject: Re: [OB PATCH] Fix uninitialized type_flags variable References: <52D7EECF.5020904@ericsson.com> In-Reply-To: <52D7EECF.5020904@ericsson.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-01/txt/msg00613.txt.bz2 On 01/16/2014 02:38 PM, Simon Marchi wrote: > If uninitialized, type_flags can contain a random value. If the > arch-specific code doesn't set a value, this give unexpected results. The whole point of that method is to get that value from the arch-specific code. If some arch-specific code is returning true but not setting type_flags, then that's the bug to fix. IOW, the method should only return true if the type_flags was set. If you're relying on this initialization, you're papering over an arch-specific bug. > > I believe this is an obvious change. Since I don't have commit access yet, > could anybody push this? > > gdb/ChangeLog > 2014-01-16 Simon Marchi > > * gdbtypes.c (address_space_name_to_int): Initialize type_flags to 0. > > diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c > index 042c17d..7d9485a 100644 > --- a/gdb/gdbtypes.c > +++ b/gdb/gdbtypes.c > @@ -531,7 +531,7 @@ lookup_function_type_with_arguments (struct type *type, > int > address_space_name_to_int (struct gdbarch *gdbarch, char *space_identifier) > { > - int type_flags; > + int type_flags = 0; > > /* Check for known address space delimiters. */ > if (!strcmp (space_identifier, "code")) > -- Pedro Alves