From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90733 invoked by alias); 14 Nov 2016 17:58:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 90713 invoked by uid 89); 14 Nov 2016 17:58:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=luis, Luis, machado, Machado X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Nov 2016 17:58:18 +0000 Received: from svr-orw-mbx-03.mgc.mentorg.com ([147.34.90.203]) by relay1.mentorg.com with esmtp id 1c6LWK-0003Zt-Gb from Luis_Gustavo@mentor.com ; Mon, 14 Nov 2016 09:58:16 -0800 Received: from [172.30.3.198] (147.34.91.1) by svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 14 Nov 2016 09:58:13 -0800 Reply-To: Luis Machado Subject: Re: [PATCH 2/3] Fix copy_bitwise() References: <1479135786-31150-1-git-send-email-arnez@linux.vnet.ibm.com> <1479135786-31150-3-git-send-email-arnez@linux.vnet.ibm.com> To: Andreas Arnez CC: From: Luis Machado Message-ID: <46271260-8e89-fd94-a380-8b7d9fae5d26@codesourcery.com> Date: Mon, 14 Nov 2016 17:58:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: svr-orw-mbx-01.mgc.mentorg.com (147.34.90.201) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00360.txt.bz2 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.