From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47698 invoked by alias); 13 Jul 2015 17:18:30 -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 47684 invoked by uid 89); 13 Jul 2015 17:18:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg20.ericsson.net Received: from usevmg20.ericsson.net (HELO usevmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 13 Jul 2015 17:18:24 +0000 Received: from EUSAAHC001.ericsson.se (Unknown_Domain [147.117.188.75]) by usevmg20.ericsson.net (Symantec Mail Security) with SMTP id 8B.1D.12958.A6793A55; Mon, 13 Jul 2015 12:48:11 +0200 (CEST) Received: from [142.133.110.144] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.77) with Microsoft SMTP Server id 14.3.210.2; Mon, 13 Jul 2015 13:18:21 -0400 Message-ID: <55A3F2DD.8010902@ericsson.com> Date: Mon, 13 Jul 2015 17:18:00 -0000 From: Simon Marchi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Doug Evans , Pedro Alves CC: gdb-patches 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> In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00381.txt.bz2 On 15-07-11 09:18 AM, Doug Evans wrote: > On Tue, Jul 7, 2015 at 11:15 AM, Pedro Alves wrote: >> ... >> 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. > > Hi. > > If we get into renaming, it would be really nice to fix another > problem with check_typedefs. > Many don't know (or forget) that it actually serves (at least) two > main purposes. > The first is the obvious removal of typedefs. > The second is the resolution of opaque types. > Forgetting the second purpose has caused bugs in the past, > and just makes the code harder to read than it should be. That's what I noticed when I was trying to get rid of check_typedef instances where the return value is ignored. I am not comfortable with having a function being used solely for its side-effects. That makes the calling code very unclear about its intentions. Why not have a separate function that only serves the second purpose? Perhaps that check_typedef could be refactored to make use of it, I don't know.