From patchwork Mon Sep 28 19:24:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 8869 Received: (qmail 1950 invoked by alias); 28 Sep 2015 19:24:49 -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 1936 invoked by uid 89); 28 Sep 2015 19:24:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_05, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-pd0-f202.google.com Received: from mail-pd0-f202.google.com (HELO mail-pd0-f202.google.com) (209.85.192.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 28 Sep 2015 19:24:46 +0000 Received: by pdbou10 with SMTP id ou10so13653502pdb.0 for ; Mon, 28 Sep 2015 12:24:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:message-id:date:subject:from:to :content-type; bh=iMnsNimkJCqZHIOb5n7I6bpj45GANHPoTnZFJGY4w4w=; b=d9/h1BI3wZxM6Z4esQt8Nk+uaDHNByG3HUautijHYymW+63pEvN685iQFhOoD0btBE iKppSz9XWch0x8RiEqPwHMWMSLMozgqZdt9cu/V5s+ET7Fb61lwsHPzmtNeDFr5OpNj5 xskKQDRdYVMzI9/O62BPPOmNTk9fXEUbD+1HI3pjWdj3R6NLNBVIZrBjkDFvfK8LkM40 J5BHqS3JcoacjZw8ZleJtQtK/tkrj/7nC5l5cZOSfWdYXj/7cuO/5HJDqFC1c10M5XFM tPzhQyfTXE7pDDl51MoX6uD3Q+W5Azd57pBDG1hhD+3fNrwZESyiV7slIG90UHOOGB1d wobg== X-Gm-Message-State: ALoCoQm2WaiBu3JGhqdQcFNo+1zbYna4+VRiVPrXO0EQvZKRhgsJLBLPSjfsa4/fdX4VPugcixJ32FLMWPN2HLzV148Joa2FpMia8tq4ZRwyJdyfJ3rA/mNpQxMc4gFEs8sZWCqtDYcDpWtaeLdRzjicj0DI4faTtpZVtoUS8Izr2BwVV0zMiFw= MIME-Version: 1.0 X-Received: by 10.66.240.138 with SMTP id wa10mr18744626pac.43.1443468284834; Mon, 28 Sep 2015 12:24:44 -0700 (PDT) Message-ID: <047d7b1121b75cef960520d3a65a@google.com> Date: Mon, 28 Sep 2015 19:24:44 +0000 Subject: [PATCH 1/3] debugging with yama: move make_cleanup_fclose From: Doug Evans To: gdb-patches@sourceware.org X-IsSubscribed: yes Hi. This patch just moves make_cleanup_fclose to a common place. [IWBN if we did not have to keep doing this piecemeal.] 2015-09-28 Doug Evans * common/filestuff.c (do_fclose_cleanup, make_cleanup_fclose): Move here ... * utils.c: ... from here. * common/filestuff.h (do_fclose_cleanup, make_cleanup_fclose): Move here ... * utils.h: ... from here. diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c index 798a411..b08f259 100644 --- a/gdb/common/filestuff.c +++ b/gdb/common/filestuff.c @@ -425,3 +425,21 @@ make_cleanup_close (int fd) *saved_fd = fd; return make_cleanup_dtor (do_close_cleanup, saved_fd, xfree); } + +/* Helper function which does the work for make_cleanup_fclose. */ + +static void +do_fclose_cleanup (void *arg) +{ + FILE *file = (FILE *) arg; + + fclose (file); +} + +/* See filestuff.h. */ + +struct cleanup * +make_cleanup_fclose (FILE *file) +{ + return make_cleanup (do_fclose_cleanup, file); +} diff --git a/gdb/common/filestuff.h b/gdb/common/filestuff.h index e997ecc..96f9e65 100644 --- a/gdb/common/filestuff.h +++ b/gdb/common/filestuff.h @@ -71,4 +71,8 @@ extern int gdb_pipe_cloexec (int filedes[2]); extern struct cleanup *make_cleanup_close (int fd); +/* Return a new cleanup that closes FILE. */ + +extern struct cleanup *make_cleanup_fclose (FILE *file); + #endif /* FILESTUFF_H */ diff --git a/gdb/utils.c b/gdb/utils.c index c7f00d9..a6b5744 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -191,24 +191,6 @@ make_cleanup_bfd_unref (bfd *abfd) return make_cleanup (do_bfd_close_cleanup, abfd); } -/* Helper function which does the work for make_cleanup_fclose. */ - -static void -do_fclose_cleanup (void *arg) -{ - FILE *file = (FILE *) arg; - - fclose (file); -} - -/* Return a new cleanup that closes FILE. */ - -struct cleanup * -make_cleanup_fclose (FILE *file) -{ - return make_cleanup (do_fclose_cleanup, file); -} - /* Helper function which does the work for make_cleanup_obstack_free. */ static void diff --git a/gdb/utils.h b/gdb/utils.h index 995a1cf..d1111fa 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -78,10 +78,6 @@ struct section_addr_info; extern struct cleanup *(make_cleanup_free_section_addr_info (struct section_addr_info *)); -/* For make_cleanup_close see common/filestuff.h. */ - -extern struct cleanup *make_cleanup_fclose (FILE *file); - extern struct cleanup *make_cleanup_bfd_unref (bfd *abfd); struct obstack;