From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20584 invoked by alias); 16 Jan 2014 18:01:45 -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 20574 invoked by uid 89); 16 Jan 2014 18:01:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 16 Jan 2014 18:01:44 +0000 Received: from EUSAAHC005.ericsson.se (Unknown_Domain [147.117.188.87]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id 1D.81.04556.68E18D25; Thu, 16 Jan 2014 19:01:42 +0100 (CET) Received: from [142.133.110.254] (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.87) with Microsoft SMTP Server (TLS) id 14.2.347.0; Thu, 16 Jan 2014 13:01:42 -0500 Message-ID: <52D81E9F.8020106@ericsson.com> Date: Thu, 16 Jan 2014 18:01:00 -0000 From: Simon Marchi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: Pedro Alves CC: GDB Patches Subject: Re: [OB PATCH] Fix uninitialized type_flags variable References: <52D7EECF.5020904@ericsson.com> <52D80AF2.5010605@redhat.com> In-Reply-To: <52D80AF2.5010605@redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-01/txt/msg00634.txt.bz2 Oh ok, thanks for the clarification. It wasn't very clear what the contract of the function was. On 14-01-16 11:38 AM, Pedro Alves wrote: > 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")) >> > >