From patchwork Fri Aug 18 20:00:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 22228 Received: (qmail 93522 invoked by alias); 18 Aug 2017 20:01:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 88952 invoked by uid 89); 18 Aug 2017 20:00:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gproxy7-pub.mail.unifiedlayer.com Received: from gproxy7-pub.mail.unifiedlayer.com (HELO gproxy7-pub.mail.unifiedlayer.com) (70.40.196.235) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Aug 2017 20:00:31 +0000 Received: from cmgw4 (unknown [10.0.90.85]) by gproxy7.mail.unifiedlayer.com (Postfix) with ESMTP id AB4D8215E74 for ; Fri, 18 Aug 2017 14:00:29 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id yk0S1v01c2f2jeq01k0Vsu; Fri, 18 Aug 2017 14:00:29 -0600 X-Authority-Analysis: v=2.2 cv=ELV26xRC c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=KeKAF7QvOSUA:10 a=zstS-IiYAAAA:8 a=izVc_uB84x-7-KHjE4wA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-24-97.hlrn.qwest.net ([75.166.24.97]:49122 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dinRS-001KNP-DU; Fri, 18 Aug 2017 14:00:26 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 2/5] Change gdb_realpath_keepfile to return a unique_xmalloc_ptr Date: Fri, 18 Aug 2017 14:00:21 -0600 Message-Id: <20170818200024.4948-3-tom@tromey.com> In-Reply-To: <20170818200024.4948-1-tom@tromey.com> References: <20170818200024.4948-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dinRS-001KNP-DU X-Source-Sender: 75-166-24-97.hlrn.qwest.net (bapiya.Home) [75.166.24.97]:49122 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This changes gdb_realpath_keepfile to return a unique_xmalloc_ptr, and fixes up the callers. ChangeLog 2017-08-18 Tom Tromey * utils.c (gdb_realpath_keepfile): Return a gdb::unique_xmalloc_ptr. * exec.c (exec_file_attach): Update. * utils.h (gdb_realpath_keepfile): Return a gdb::unique_xmalloc_ptr. --- gdb/ChangeLog | 8 ++++++++ gdb/exec.c | 2 +- gdb/utils.c | 6 +++--- gdb/utils.h | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e75d1b7..ec022c3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2017-08-18 Tom Tromey + * utils.c (gdb_realpath_keepfile): Return a + gdb::unique_xmalloc_ptr. + * exec.c (exec_file_attach): Update. + * utils.h (gdb_realpath_keepfile): Return a + gdb::unique_xmalloc_ptr. + +2017-08-18 Tom Tromey + * compile/compile.c (compile_file_command): Use gdb::unique_xmalloc_ptr, std::string. * utils.c (gdb_abspath): Change return type. diff --git a/gdb/exec.c b/gdb/exec.c index 6980b07..45bc133 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -352,7 +352,7 @@ exec_file_attach (const char *filename, int from_tty) if (load_via_target) exec_filename = xstrdup (bfd_get_filename (exec_bfd)); else - exec_filename = gdb_realpath_keepfile (scratch_pathname); + exec_filename = gdb_realpath_keepfile (scratch_pathname).release (); if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) { diff --git a/gdb/utils.c b/gdb/utils.c index 9959c01..5bdc638 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2716,7 +2716,7 @@ gdb_realpath (const char *filename) /* Return a copy of FILENAME, with its directory prefix canonicalized by gdb_realpath. */ -char * +gdb::unique_xmalloc_ptr gdb_realpath_keepfile (const char *filename) { const char *base_name = lbasename (filename); @@ -2727,7 +2727,7 @@ gdb_realpath_keepfile (const char *filename) /* Extract the basename of filename, and return immediately a copy of filename if it does not contain any directory prefix. */ if (base_name == filename) - return xstrdup (filename); + return gdb::unique_xmalloc_ptr (xstrdup (filename)); dir_name = (char *) alloca ((size_t) (base_name - filename + 2)); /* Allocate enough space to store the dir_name + plus one extra @@ -2756,7 +2756,7 @@ gdb_realpath_keepfile (const char *filename) result = concat (real_path, SLASH_STRING, base_name, (char *) NULL); xfree (real_path); - return result; + return gdb::unique_xmalloc_ptr (result); } /* Return PATH in absolute form, performing tilde-expansion if necessary. diff --git a/gdb/utils.h b/gdb/utils.h index a2a959f..477257b 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -254,7 +254,7 @@ extern struct cleanup *make_bpstat_clear_actions_cleanup (void); extern char *gdb_realpath (const char *); -extern char *gdb_realpath_keepfile (const char *); +extern gdb::unique_xmalloc_ptr gdb_realpath_keepfile (const char *); extern gdb::unique_xmalloc_ptr gdb_abspath (const char *);