This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Regression: Re: [PATCH 2/6] Code cleanup: dwarf2read.c: Eliminate ::file_write
- From: Pedro Alves <palves at redhat dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 19 Jun 2017 10:27:46 +0100
- Subject: Re: Regression: Re: [PATCH 2/6] Code cleanup: dwarf2read.c: Eliminate ::file_write
- Authentication-results: sourceware.org; auth=none
- 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=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7C16F81241
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7C16F81241
- References: <8efc0742-1014-4fe0-6948-f40a9c5c4975@redhat.com> <1497284051-13795-2-git-send-email-palves@redhat.com> <20170618183603.GA1834@host1.jankratochvil.net>
On 06/18/2017 07:36 PM, Jan Kratochvil wrote:
>> @@ -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.
No it's not. The fwrite call is no longer in generic code where
the element type is unknown. Here m_vec is a vector of gdb_byte, and
gdb_byte is guaranteed to have sizeof == 1.
Thanks,
Pedro Alves