From: Luis Machado <lgustavo@codesourcery.com>
To: Andreas Arnez <arnez@linux.vnet.ibm.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH 2/3] Fix copy_bitwise()
Date: Mon, 14 Nov 2016 17:58:00 -0000 [thread overview]
Message-ID: <46271260-8e89-fd94-a380-8b7d9fae5d26@codesourcery.com> (raw)
In-Reply-To: <m37f86vtf6.fsf@oc1027705133.ibm.com>
On 11/14/2016 11:54 AM, Andreas Arnez wrote:
> 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?
>
Well, obviously i wasn't fully awake. Nevermind this.
> [...]
>
>>> + /* 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.
>
No strong opinions there. Just a suggestion.
next prev parent reply other threads:[~2016-11-14 17:58 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
2016-11-14 17:58 ` Luis Machado [this message]
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=46271260-8e89-fd94-a380-8b7d9fae5d26@codesourcery.com \
--to=lgustavo@codesourcery.com \
--cc=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
/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