This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [OB PATCH] Fix uninitialized type_flags variable
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>
- Date: Thu, 16 Jan 2014 13:02:07 -0500
- Subject: Re: [OB PATCH] Fix uninitialized type_flags variable
- Authentication-results: sourceware.org; auth=none
- References: <52D7EECF dot 5020904 at ericsson dot com> <52D80AF2 dot 5010605 at redhat dot com>
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 <simon.marchi@ericsson.com>
>>
>> * 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"))
>>
>
>