From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92006 invoked by alias); 8 Jul 2015 12:05:57 -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 91995 invoked by uid 89); 8 Jul 2015 12:05:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 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; Wed, 08 Jul 2015 12:05:55 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 7D4ABC795B; Wed, 8 Jul 2015 12:05:54 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t68C5qwb030163; Wed, 8 Jul 2015 08:05:53 -0400 Message-ID: <559D1220.1060708@redhat.com> Date: Wed, 08 Jul 2015 12:05: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] Delete program spaces directly when removing inferiors References: <1412022790-21931-1-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1412022790-21931-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/msg00201.txt.bz2 On 09/29/2014 09:33 PM, Simon Marchi wrote: > -void > -delete_inferior (int pid) > -{ > - struct inferior *inf = find_inferior_pid (pid); > - > - delete_inferior_1 (inf, 0); > - > - if (print_inferior_events) > - printf_unfiltered (_("[Inferior %d exited]\n"), pid); > -} > + /* If this program space is rendered useless, remove it. */ > + if (program_space_empty_p (inf->pspace)) > + delete_program_space (inf->pspace); I think there's something odd with indentation here. > - struct program_space *ss, **ss_link; > - struct program_space *current = current_program_space; > + gdb_assert(pspace != NULL); > + gdb_assert(pspace != current_program_space); > > - ss = program_spaces; > - ss_link = &program_spaces; > - while (ss) > + if (pspace == program_spaces) > + program_spaces = pspace->next; > + else > { > - if (ss == current || !pspace_empty_p (ss)) > + struct program_space *i = program_spaces; > + > + for (i = program_spaces; i != NULL; i = i->next) > { > - ss_link = &ss->next; > - ss = *ss_link; > - continue; > + if (i->next == pspace) > + { > + i->next = i->next->next; > + break; > + } > } > - > - *ss_link = ss->next; > - release_program_space (ss); > - ss = *ss_link; > } I don't find this conversion from while to if+else+for an improvement. You can instead write: ss = program_spaces; ss_link = &program_spaces; while (ss != NULL) { if (ss == pspace) { *ss_link = ss->next; break; } ss_link = &ss->next; ss = *ss_link; } release_program_space (pspace); We use this _link pattern in several places. OK with that change. Thanks, Pedro Alves