This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (2/4)
On 05/24/2017 10:07 AM, Alan Hayward wrote:
> /* Copy COPY_LEN bytes from SOURCE to DEST, then sign extend or zero extend
> to FILL_LEN bytes. */
> void copy_and_fill_to_size (const gdb_byte *dest, const gdb_byte *source,
> int copy_len, int fill_len, bool is_signed,
> enum bfd_endian byte_order)
> {
> signed int len_diff = fill_len - copy_len;
> gdb_assert (len_diff >= 0);
>
> if (byte_order == BFD_ENDIAN_BIG)
> memcpy (dest+len_diff, source, copy_len);
> else
> memcpy (dest, source, copy_len);
Note here I was thinking you'd need to handle truncation as well.
I.e., only copy fill_len bytes when fill_len is narrower than
copy_len. So I'd probably rename copy_len/fill_len to dest_len/source_len
to match 'dest' and 'source', and name the function something
else that doesn't have "fill" in it.
Thanks,
Pedro Alves