From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119551 invoked by alias); 21 Aug 2019 17:34:05 -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 119499 invoked by uid 89); 21 Aug 2019 17:34:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= 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 ESMTP; Wed, 21 Aug 2019 17:33:59 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78F1F307D921; Wed, 21 Aug 2019 17:33:58 +0000 (UTC) Received: from localhost (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48F186012C; Wed, 21 Aug 2019 17:33:58 +0000 (UTC) From: Sergio Durigan Junior To: Christian Biesinger Cc: Christian Biesinger via gdb-patches Subject: Re: [PATCH 1/3] Refactor get_init_files to use std::string References: <20190820221745.147370-1-cbiesinger@google.com> <20190820221745.147370-2-cbiesinger@google.com> <87v9uqjvav.fsf@redhat.com> Date: Wed, 21 Aug 2019 17:34:00 -0000 In-Reply-To: (Christian Biesinger's message of "Wed, 21 Aug 2019 12:28:42 -0500") Message-ID: <87h86ajud6.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00495.txt.bz2 On Wednesday, August 21 2019, Christian Biesinger wrote: >> > - char *relocated_sysgdbinit; >> > + std::string relocated_sysgdbinit; >> > >> > /* If SYSTEM_GDBINIT lives in data-directory, and data-directory >> > has been provided, search for SYSTEM_GDBINIT there. */ >> > @@ -226,28 +225,30 @@ get_init_files (const char **system_gdbinit, >> > { >> > /* Append the part of SYSTEM_GDBINIT that follows GDB_DATADIR >> > to gdb_datadir. */ >> > - char *tmp_sys_gdbinit = xstrdup (&SYSTEM_GDBINIT[datadir_len]); >> > - char *p; >> > >> > - for (p = tmp_sys_gdbinit; IS_DIR_SEPARATOR (*p); ++p) >> > + size_t start = datadir_len; >> > + for (; IS_DIR_SEPARATOR (SYSTEM_GDBINIT[start]); ++start) >> > continue; >> >> This seems wrong; you're starting the iteration from >> 'SYSTEM_GDBINIT[start]', but 'start' is 'datadir_len'. > > The previous version first initialized tmp_sys_gdbinit to start from > &SYSTEM_GDBINIT[datadir_len], so I think my change is correct (and > simpler)? Ah, right, now I see the '&SYSTEM_GDBINIT[datadir_len]' there. That looks fine, then. Thanks! -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/