This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Add OSE operating system support [1/5] ose core format support of bfd
- From: Tom Tromey <tromey at redhat dot com>
- To: Hui Zhu <hui_zhu at mentor dot com>
- Cc: <gdb-patches at sourceware dot org>, <binutils at sourceware dot org>, <lgustavo at codesourcery dot com>, Eli Zaretskii <eliz at gnu dot org>
- Date: Fri, 19 Apr 2013 12:46:56 -0600
- Subject: Re: [PATCH] Add OSE operating system support [1/5] ose core format support of bfd
- References: <5135C146 dot 1030303 at mentor dot com> <5135C1A7 dot 7020005 at mentor dot com>
>>>>> "Hui" == Hui Zhu <hui_zhu@mentor.com> writes:
Hui> OSE's core file format is different compared to Linux, so there is
Hui> patch for bfd to handle this format.
I skimmed this a little and a couple things caught my attention.
Hui> +struct ose_core_struct
Hui> +{
Hui> + /* FIXME: we aren't setting these anywhere yet. */
Hui> + int sig;
Hui> + int bid;
Hui> +};
If that is the case, why not just delete this entirely?
You can re-add it whenever it is needed.
Hui> +/* FIXME: should not be a global. */
Hui> +int last_data_section;
I think this can just be a local variable where it is used.
Hui> +static bfd_boolean
Hui> +zlib_inflate_buffer (bfd_byte *compressed_buffer,
Hui> + size_t compressed_size,
Hui> + bfd_byte *uncompressed_buffer,
Hui> + bfd_size_type uncompressed_size)
[...]
Hui> + rc = inflateInit (&strm);
Hui> + while (strm.avail_in > 0)
Hui> + {
Hui> + if (rc != Z_OK)
Hui> + return FALSE;
Hui> + strm.next_out = ((Bytef *) uncompressed_buffer
Hui> + + (uncompressed_size - strm.avail_out));
Hui> + rc = inflate (&strm, Z_FINISH);
Hui> + if (rc != Z_STREAM_END)
Hui> + return FALSE;
Hui> + rc = inflateReset (&strm);
Hui> + }
Hui> + rc = inflateEnd (&strm);
Hui> + if (rc != Z_OK
Hui> + || strm.avail_out != 0)
Hui> + return FALSE;
This can leak memory at the 'return FALSE' statements in the loop.
I think it should call inflateEnd before each return.
Tom