From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16032 invoked by alias); 8 Mar 2010 18:55:19 -0000 Received: (qmail 16015 invoked by uid 22791); 8 Mar 2010 18:55:19 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 08 Mar 2010 18:55:13 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 2DE9A2BAB45; Mon, 8 Mar 2010 13:55:12 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id YPsrc5nBvXhm; Mon, 8 Mar 2010 13:55:12 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 9EFEC2BAB3D; Mon, 8 Mar 2010 13:55:11 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id A5120F5894; Mon, 8 Mar 2010 22:54:50 +0400 (RET) Date: Mon, 08 Mar 2010 18:55:00 -0000 From: Joel Brobecker To: Pierre Muller Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] avoid GDB crash on inspection of pascal arrays Message-ID: <20100308185450.GK3081@adacore.com> References: <001801cabee0$31499ca0$93dcd5e0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001801cabee0$31499ca0$93dcd5e0$@muller@ics-cnrs.unistra.fr> User-Agent: Mutt/1.5.20 (2009-06-14) 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 X-SW-Source: 2010-03/txt/msg00325.txt.bz2 Hi Pierre, > 2020-03-08 Pierre Muller > > * p-lang.c (is_pascal_string_type): Check that TYPE arg is non NULL. Seems odd that you'd call a function whose job is to inspect a type with a NULL type, but it's not hard to add a check indeed - and that would not. be the first time ;-). Please do not consider this an objection, just "speaking" aloud... Just one nit: > - if (TYPE_CODE (type) == TYPE_CODE_STRUCT) > + if ((type != NULL) && (TYPE_CODE (type) == TYPE_CODE_STRUCT)) Would you mind removing the extra parenthesis around each block? I'd like for the code to be as consistent as possible, to help readability. It's a question of taste, and I don't agree with all our rules, but I'd like for things to stay as consistent as possible... While I'm sending you an email, I started looking at the call sites for your function, to see if I could see why the function is called with a NULL pointer, in case there was something obvious to be found. Nothing obvious, but I noticed that some code in p-valprint might need a little reformatting? > elttype = check_typedef (TYPE_TARGET_TYPE (type)); > { > addr = unpack_pointer (type, valaddr + embedded_offset); > print_unpacked_pointer: > elttype = check_typedef (TYPE_TARGET_TYPE (type)); > > if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) (this is around line 153). Something else that caught my attention, as well, is the following statement is repeated twice: elttype = check_typedef (TYPE_TARGET_TYPE (type)); It looks like the first instance is really unnecessary now? (I am guessing there was a "if" before the mis-indented curly brace before, and that this "if" got removed, but not its body, to keep the patch readable - although there is always the diff -w option). How about the curly brace themselves - since the block does not introduce new local variables, it looks like it can go too. -- Joel