Received: from eggs.gnu.org ([2001:4830:134:3::10]:56328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9KYV-0001nz-TA for qemu-devel@nongnu.org; Sat, 04 Jun 2016 19:00:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9KYR-0000Zk-Q3 for qemu-devel@nongnu.org; Sat, 04 Jun 2016 19:00:34 -0400 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:35021) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9KYR-0000Zg-I5 for qemu-devel@nongnu.org; Sat, 04 Jun 2016 19:00:31 -0400 Received: by mail-pf0-x234.google.com with SMTP id g64so55079382pfb.2 for ; Sat, 04 Jun 2016 16:00:31 -0700 (PDT) Sender: Richard Henderson References: <1464898022-97990-1-git-send-email-rolnik@amazon.com> <1464898022-97990-7-git-send-email-rolnik@amazon.com> From: Richard Henderson Message-ID: <7a239c22-ff38-79ed-c31b-8e8e4146b22b@twiddle.net> Date: Sat, 4 Jun 2016 16:00:28 -0700 MIME-Version: 1.0 In-Reply-To: <1464898022-97990-7-git-send-email-rolnik@amazon.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/10] target-avr: adding instruction decoder List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Rolnik , qemu-devel@nongnu.org Cc: Michael Rolnik On 06/02/2016 01:06 PM, Michael Rolnik wrote: > +uint32_t avr_decode(uint32_t pc, uint32_t *length, uint32_t code, translate_function_t *translate) > +{ > + uint32_t opcode = extract32(code, 0, 16); > + switch (opcode & 0x0000d000) { > + case 0x00000000: { > + uint32_t opcode = extract32(code, 0, 16); > + switch (opcode & 0x00002c00) { > + case 0x00000000: { > + uint32_t opcode = extract32(code, 0, 16); Why do you keep extracting the same value into variables that shadow each other? I can only assume that this is machine-generated code. Is there any reason that you want to commit the quite unreadable generated code instead of the original input and generator? > + *translate = (translate_function_t)&avr_translate_NOP; The casts are, in this and other cases, unnecessary, and could easily mask a real problem. > + return 0; Since you only ever return 0, what's the point of the return value? r~