Re: Regression: Re: [PATCH 2/6] Code cleanup: dwarf2read.c: Eliminate ::file_write

Pedro Alves
2017-06-19T09:27:56Z

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