From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: Luis Machado <lgustavo@codesourcery.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH 2/3] Fix copy_bitwise()
Date: Mon, 14 Nov 2016 17:54:00 -0000 [thread overview]
Message-ID: <m37f86vtf6.fsf@oc1027705133.ibm.com> (raw)
In-Reply-To: <b3cfb6af-816a-c486-4483-e0cc652fbc79@codesourcery.com> (Luis Machado's message of "Mon, 14 Nov 2016 09:38:06 -0600")
On Mon, Nov 14 2016, Luis Machado wrote:
> On 11/14/2016 09:02 AM, Andreas Arnez wrote:
[...]
>> + dest += dest_offset / 8;
>> + dest_offset %= 8;
>> + source += source_offset / 8;
>> + source_offset %= 8;
>
> Are you sure you will always have non-zero source_offset and dest_offset
> when explicitly dividing them by 8? If i were to feed (or GDB, in some
> erroneous state) invalid data to the function, this would likely crash?
>
> There are other cases of explicit / operations.
No, copy_bitwise should work fine with source_offset and dest_offset set
to zero. Where do you think it would crash?
[...]
>> + /* Fill BUF with DEST_OFFSET bits from the destination and 8 -
>> + SOURCE_OFFSET bits from the source. */
>> + buf = *(bits_big_endian ? source-- : source++) >> source_offset;
>
> Maybe it's just me, but having constructs like the above don't help much
> performance-wise and make the code slightly less readable. Should we
> expand this further? There are multiple occurrences of this.
Well, I've tried a few different ways and found this approach actually
the easiest to read, for my taste. For instance, it makes the multiple
occurrences easy to recognize -- as you pointed out ;-)
Of course, if people feel that this post-decrement/increment pattern
really hurts readability, I can provide a more "stretched" form instead.
> Also, should we harden the method to prevent dereferencing NULL source or
> dest?
I wouldn't consider that necessary, but I'm open for other opinions.
[...]
> Otherwise it looks good to me.
Thanks!
--
Andreas
next prev parent reply other threads:[~2016-11-14 17:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-14 15:03 [PATCH 0/3] Support DW_AT_data_bit_offset Andreas Arnez
2016-11-14 15:04 ` [PATCH 2/3] Fix copy_bitwise() Andreas Arnez
2016-11-14 15:38 ` Luis Machado
2016-11-14 17:54 ` Andreas Arnez [this message]
2016-11-14 17:58 ` Luis Machado
2016-11-15 18:58 ` Andreas Arnez
2016-11-15 19:42 ` Pedro Alves
2016-11-17 19:36 ` Andreas Arnez
2016-11-17 20:30 ` Pedro Alves
2016-11-18 15:06 ` Andreas Arnez
2016-11-22 23:18 ` Pedro Alves
2016-11-24 16:15 ` Andreas Arnez
2016-11-24 16:32 ` Pedro Alves
2016-11-24 16:55 ` Andreas Arnez
2016-11-14 15:04 ` [PATCH 1/3] Fix PR12616 - gdb does not implement DW_AT_data_bit_offset Andreas Arnez
2016-11-14 15:38 ` Luis Machado
2016-11-14 15:05 ` [PATCH 3/3] Optimize byte-aligned copies in copy_bitwise() Andreas Arnez
2016-11-14 15:38 ` Luis Machado
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m37f86vtf6.fsf@oc1027705133.ibm.com \
--to=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=lgustavo@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox