From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14817 invoked by alias); 6 Mar 2019 19:32:56 -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 14809 invoked by uid 89); 6 Mar 2019 19:32:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=BAYES_00,DNS_FROM_AHBL_RHSBL,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.1 spammy=our X-HELO: mail-wr1-f67.google.com Received: from mail-wr1-f67.google.com (HELO mail-wr1-f67.google.com) (209.85.221.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Mar 2019 19:32:46 +0000 Received: by mail-wr1-f67.google.com with SMTP id f14so14753958wrg.1 for ; Wed, 06 Mar 2019 11:32:45 -0800 (PST) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4c97:6d52:2cea:997b? ([2001:8a0:f913:f700:4c97:6d52:2cea:997b]) by smtp.gmail.com with ESMTPSA id w24sm1357806wmi.40.2019.03.06.11.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Mar 2019 11:32:43 -0800 (PST) Subject: Re: [PATCH v2 07/22] Remove last cleanups from solib-svr4.c To: Tom Tromey , gdb-patches@sourceware.org References: <20190227201849.32210-1-tom@tromey.com> <20190227201849.32210-8-tom@tromey.com> From: Pedro Alves Message-ID: Date: Wed, 06 Mar 2019 19:32:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190227201849.32210-8-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-03/txt/msg00120.txt.bz2 On 02/27/2019 08:18 PM, Tom Tromey wrote: > This removes the last cleanups from solib-svr4.c, replacing them with > uses of make_scope_exit. > > gdb/ChangeLog > 2019-02-27 Tom Tromey > > * solib-svr4.c (svr4_parse_libraries, svr4_current_sos_direct): > Use make_scope_exit. > --- > gdb/ChangeLog | 5 +++++ > gdb/solib-svr4.c | 17 ++++++++++------- > 2 files changed, 15 insertions(+), 7 deletions(-) > > diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c > index 2b370ef96d0..2301cf94c2f 100644 > --- a/gdb/solib-svr4.c > +++ b/gdb/solib-svr4.c > @@ -1198,8 +1198,10 @@ static const struct gdb_xml_element svr4_library_list_elements[] = > static int > svr4_parse_libraries (const char *document, struct svr4_library_list *list) > { > - struct cleanup *back_to = make_cleanup (svr4_free_library_list, > - &list->head); > + auto cleanup = make_scope_exit ([&] () > + { > + svr4_free_library_list (&list->head); > + }); > When passing lambdas as last argument to a function, I think indenting like this reads clearer: auto cleanup = make_scope_exit ([&] () { svr4_free_library_list (&list->head); }); Makes it read more like an if/for scope block, and of course, avoids aligning things too much to the right side. Examples of this can be found throughout gdbserver, for example: for_each_thread ([] (thread_info *thread) { thread->status_pending_p = 0; }); and, also, that's how you'd indent if you used SCOPE_EXIT instead: SCOPE_EXIT { svr4_free_library_list (&list->head); } LLVM has a written rule for this: https://llvm.org/docs/CodingStandards.html#format-lambdas-like-blocks-of-code If others agree, I'd vote for having a similar rule of our own. Otherwise, LGTM. Thanks, Pedro Alves