From patchwork Tue Jul 25 17:20:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 21770 Received: (qmail 40897 invoked by alias); 25 Jul 2017 17:26:09 -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 40878 invoked by uid 89); 25 Jul 2017 17:26:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 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: gproxy2-pub.mail.unifiedlayer.com Received: from gproxy2-pub.mail.unifiedlayer.com (HELO gproxy2-pub.mail.unifiedlayer.com) (69.89.18.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Jul 2017 17:26:07 +0000 Received: from cmgw4 (unknown [10.0.90.85]) by gproxy2.mail.unifiedlayer.com (Postfix) with ESMTP id 8AA931E1B2F for ; Tue, 25 Jul 2017 11:21:17 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id p5ME1v00V2f2jeq015MHLD; Tue, 25 Jul 2017 11:21:17 -0600 X-Authority-Analysis: v=2.2 cv=G/hsK5s5 c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=G3gG6ho9WtcA:10 a=zstS-IiYAAAA:8 a=c4UGnGtsIrf7KWlcvI4A:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-29-39-24.hlrn.qwest.net ([174.29.39.24]:55470 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1da3WE-0015gW-BH; Tue, 25 Jul 2017 11:21:14 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v2 04/24] Use gdb_file_up in fbsd-nat.c Date: Tue, 25 Jul 2017 11:20:47 -0600 Message-Id: <20170725172107.9799-5-tom@tromey.com> In-Reply-To: <20170725172107.9799-1-tom@tromey.com> References: <20170725172107.9799-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1da3WE-0015gW-BH X-Source-Sender: 174-29-39-24.hlrn.qwest.net (bapiya.Home) [174.29.39.24]:55470 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This updates fbsd-nat.c to use gdb_file_up. This removes a use of a cleanup, and helps remove make_cleanup_fclose in a later patch. I have no way to test this patch. ChangeLog 2017-07-25 Tom Tromey * fbsd-nat.c (fbsd_find_memory_regions): Update. --- gdb/ChangeLog | 4 ++++ gdb/fbsd-nat.c | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fc9d184..ab0a51f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2017-07-25 Tom Tromey + * fbsd-nat.c (fbsd_find_memory_regions): Update. + +2017-07-25 Tom Tromey + * cli/cli-cmds.c (find_and_open_script): Change return type. Remove "streamp" and "full_path" parameters. (source_script_with_search): Update. diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 85f5605..833f460 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -161,7 +161,6 @@ fbsd_find_memory_regions (struct target_ops *self, { pid_t pid = ptid_get_pid (inferior_ptid); char *mapfilename; - FILE *mapfile; unsigned long start, end, size; char protection[4]; int read, write, exec; @@ -169,17 +168,16 @@ fbsd_find_memory_regions (struct target_ops *self, mapfilename = xstrprintf ("/proc/%ld/map", (long) pid); cleanup = make_cleanup (xfree, mapfilename); - mapfile = fopen (mapfilename, "r"); + gdb_file_up mapfile = fopen (mapfilename, "r"); if (mapfile == NULL) error (_("Couldn't open %s."), mapfilename); - make_cleanup_fclose (mapfile); if (info_verbose) fprintf_filtered (gdb_stdout, "Reading memory regions from %s\n", mapfilename); /* Now iterate until end-of-file. */ - while (fbsd_read_mapping (mapfile, &start, &end, &protection[0])) + while (fbsd_read_mapping (mapfile.get (), &start, &end, &protection[0])) { size = end - start;