From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122057 invoked by alias); 7 Jul 2015 16:15:19 -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 122036 invoked by uid 89); 7 Jul 2015 16:15:18 -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,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 07 Jul 2015 16:15:17 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 84B2B8F019; Tue, 7 Jul 2015 16:15:16 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t67GFFZL020974; Tue, 7 Jul 2015 12:15:15 -0400 Message-ID: <559BFB12.6050606@redhat.com> Date: Tue, 07 Jul 2015 16:15:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH] Remove CHECK_TYPEDEF, use check_typedef instead References: <1436213157-21480-1-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1436213157-21480-1-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-07/txt/msg00179.txt.bz2 On 07/06/2015 09:05 PM, Simon Marchi wrote: > I think that the CHECK_TYPEDEF macro is not necessary, and even a bit > annoying. It makes unclear the fact that the "type" variables gets > overwritten. It has actually bitten me a few times. I think the > following, explicit form, is better. > > type = check_typedef (type); > I don't have a strong opinion either. Whatever's fine with others is fine with me. Playing devil's advocate, the CHECK_TYPEDEF macro has the advantage that makes it clear that you want to peel away typedefs are don't really care about the original type. I'd argue that the real issue with the macro is that it takes the type pointer argument "by non-const reference to pointer". Another solution would be to make it a function/macro that instead takes a pointer to a type pointer. Something like: void CHECK_TYPEDEFS (struct type **type) { *type = check_typedef (*type); } Then you'd write: > - CHECK_TYPEDEF (result); > + CHECK_TYPEDEF (&result); Or even rename it while at it: void peel_typedefs (struct type **type) { *type = check_typedef (*type); } And so you'd write: > - CHECK_TYPEDEF (result); > + peel_typedefs (&result); Then the code ends up self documenting, and there's no way to forget to assign the return of the function back to the argument. Thanks, Pedro Alves