From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100268 invoked by alias); 18 Jun 2017 18:36: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 100258 invoked by uid 89); 18 Jun 2017 18:36:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD,UNSUBSCRIBE_BODY autolearn=no version=3.3.2 spammy=Hx-languages-length:1259 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; Sun, 18 Jun 2017 18:36:03 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E36498123A for ; Sun, 18 Jun 2017 18:36:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E36498123A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jan.kratochvil@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E36498123A Received: from host1.jankratochvil.net (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3014B183AE; Sun, 18 Jun 2017 18:36:05 +0000 (UTC) Date: Sun, 18 Jun 2017 18:36:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Regression: Re: [PATCH 2/6] Code cleanup: dwarf2read.c: Eliminate ::file_write Message-ID: <20170618183603.GA1834@host1.jankratochvil.net> References: <8efc0742-1014-4fe0-6948-f40a9c5c4975@redhat.com> <1497284051-13795-2-git-send-email-palves@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1497284051-13795-2-git-send-email-palves@redhat.com> User-Agent: Mutt/1.8.0 (2017-02-23) X-SW-Source: 2017-06/txt/msg00480.txt.bz2 On Mon, 12 Jun 2017 18:14:07 +0200, Pedro Alves wrote: > There's no real need for all this indirection. ... > -/* 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")); > } It is a regression as one needs to multiply vector.size() by sizeof(vector[0]). Which is also why I separated determining the memory block boundaries from checking the write success. Jan