From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80411 invoked by alias); 7 Jul 2015 22:01:54 -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 80362 invoked by uid 89); 7 Jul 2015 22:01:54 -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 22:01:53 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id F3DCFB8BDF; Tue, 7 Jul 2015 22:01:51 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t67M1oZG003241; Tue, 7 Jul 2015 18:01:51 -0400 Message-ID: <559C4C4E.9050109@redhat.com> Date: Tue, 07 Jul 2015 22:01: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> <559BFB12.6050606@redhat.com> <559C3349.1050501@ericsson.com> In-Reply-To: <559C3349.1050501@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-07/txt/msg00193.txt.bz2 On 07/07/2015 09:15 PM, Simon Marchi wrote: > That's a bit better, but I don't think there's an advantage here of > having two ways to do the same thing. If anything, it's confusing for > new contributors. OK. > > I was going to suggest adding __attribute__((warn_unused_result)) to > check_typedef, as it would also prevent forgetting assigning the result. > Especially if we change it, people used to the old macro would be at > risk of forgetting it. However, I realized that at a few places the > result of check_typedef is ignored. It is used only to initialize the > length field of the typedef, so that TYPE_LENGTH (the_typedef) will > return the right thing [1]. > > Using a side-effect of check_typedef to get the length of the type right > seems very hackish and error-prone (easy to forget something or to break > something when moving code around). > > I think there should be a get_type_length [2] function that returns what > you would expect: the actual length of the type, after having peeled all > layers of typedef. You wouldn't need to call check_typedef beforehand. I'd be fine with it. > It would be cleaner and safer, and would allow us to add warn_unused_result > to check_typedef. Because there should be no reason to call check_typedef > than to obtain the resolved type. > > Thoughts? > > [1] For example: https://github.com/simark/binutils-gdb/blob/master/gdb/tracepoint.c#L1532 > [2] I can see a get_type_length function mentioned in the ChangeLog here: > > https://github.com/simark/binutils-gdb/blob/master/gdb/ChangeLog-2014#L9750 > > but I can't find any trace of it in the source code (even when checkout out > that commit). Any idea? Joel perhaps? Looks like it was present in earlier revisions of the patch, but later dropped: Gooling for '"get_type_length" sanimir' found it: https://sourceware.org/ml/gdb-patches/2013-12/msg00127.html Thanks, Pedro Alves