From patchwork Mon Jun 12 16:14:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 20956 Received: (qmail 88154 invoked by alias); 12 Jun 2017 16:14:12 -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 86770 invoked by uid 89); 12 Jun 2017 16:14:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD, UNSUBSCRIBE_BODY autolearn=ham version=3.3.2 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; Mon, 12 Jun 2017 16:14:09 +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 3A212C01CB7F for ; Mon, 12 Jun 2017 16:14:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3A212C01CB7F Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3A212C01CB7F Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE4F880F6C for ; Mon, 12 Jun 2017 16:14:12 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/6] Code cleanup: dwarf2read.c: Eliminate ::file_write Date: Mon, 12 Jun 2017 17:14:07 +0100 Message-Id: <1497284051-13795-2-git-send-email-palves@redhat.com> In-Reply-To: <1497284051-13795-1-git-send-email-palves@redhat.com> References: <1497284051-13795-1-git-send-email-palves@redhat.com> In-Reply-To: <8efc0742-1014-4fe0-6948-f40a9c5c4975@redhat.com> References: <8efc0742-1014-4fe0-6948-f40a9c5c4975@redhat.com> There's no real need for all this indirection. gdb/ChangeLog: 2017-06-12 Pedro Alves * dwarf2read.c (file_write(FILE *, const void *, size_t)): Delete. (file_write (FILE *, const std::vector&)): Delete. (data_buf::file_write): Call ::fwrite directly. --- gdb/ChangeLog | 6 ++++++ gdb/dwarf2read.c | 22 ++-------------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 316e03a..e3e980d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2017-06-12 Pedro Alves + * dwarf2read.c (file_write(FILE *, const void *, size_t)): Delete. + (file_write (FILE *, const std::vector&)): Delete. + (data_buf::file_write): Call ::fwrite directly. + +2017-06-12 Pedro Alves + * dwarf2read.c (uniquify_cu_indices): Use std::unique and std::vector::erase. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 0c9e275..55b3033 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -23195,25 +23195,6 @@ dwarf2_per_objfile_free (struct objfile *objfile, void *d) /* The "save gdb-index" command. */ -/* Write SIZE bytes from the buffer pointed to by DATA to FILE, with - error checking. */ - -static void -file_write (FILE *file, const void *data, size_t size) -{ - if (fwrite (data, 1, size, file) != size) - error (_("couldn't data write to file")); -} - -/* Write the contents of VEC to FILE, with error checking. */ - -template -static void -file_write (FILE *file, const std::vector &vec) -{ - file_write (file, vec.data (), vec.size() * sizeof (vec[0])); -} - /* In-memory buffer to prepare data to be written later to a file. */ class data_buf { @@ -23252,7 +23233,8 @@ public: /* Write the buffer to FILE. */ void file_write (FILE *file) const { - ::file_write (file, m_vec); + if (::fwrite (m_vec.data (), 1, m_vec.size (), file) != m_vec.size ()) + error (_("couldn't write data to file")); } private: