Message ID | 20210807110939.95853-2-f4bug@amsat.org |
---|---|
State | New |
Headers | show |
Series | disas/nios2: Simplify endianess conversion | expand |
On 07/08/2021 13.09, Philippe Mathieu-Daudé wrote: > We are going to modify this function, fix its style first. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > disas/nios2.c | 53 +++++++++++++++++++++++++-------------------------- > 1 file changed, 26 insertions(+), 27 deletions(-) I guess it'd make sense to either re-indent the whole file or to bite the bullet and life with the checkpatch warnings here ... otherwise you now have one function that matches the QEMU coding style while the rest of the file looks completely different. OTOH, we still can clean that up later, so in case you want to keep this patch: Reviewed-by: Thomas Huth <thuth@redhat.com>
+Peter for overall style recommendation. On 8/9/21 8:08 AM, Thomas Huth wrote: > On 07/08/2021 13.09, Philippe Mathieu-Daudé wrote: >> We are going to modify this function, fix its style first. >> >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> >> --- >> disas/nios2.c | 53 +++++++++++++++++++++++++-------------------------- >> 1 file changed, 26 insertions(+), 27 deletions(-) > > I guess it'd make sense to either re-indent the whole file or to bite > the bullet and life with the checkpatch warnings here ... otherwise you > now have one function that matches the QEMU coding style while the rest > of the file looks completely different. Yeah I didn't know what to do here, I remember a discussion (3 years ago?) "disas/..." is old import from binutils libopcode, so better not diverge the style. But the capstone updates shuffled things a bit. And nobody is tracking the parent project. I'm tempted to keep the style and ignore the warnings. > OTOH, we still can clean that up later, so in case you want to keep this > patch: > > Reviewed-by: Thomas Huth <thuth@redhat.com> Thanks.
Le 07/08/2021 à 13:09, Philippe Mathieu-Daudé a écrit : > We are going to modify this function, fix its style first. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > disas/nios2.c | 53 +++++++++++++++++++++++++-------------------------- > 1 file changed, 26 insertions(+), 27 deletions(-) > > diff --git a/disas/nios2.c b/disas/nios2.c > index c3e82140c79..d124902ae3e 100644 > --- a/disas/nios2.c > +++ b/disas/nios2.c > @@ -3482,38 +3482,37 @@ static int > print_insn_nios2 (bfd_vma address, disassemble_info *info, > enum bfd_endian endianness) > { > - bfd_byte buffer[INSNLEN]; > - int status; > + bfd_byte buffer[INSNLEN]; > + int status; > > - status = (*info->read_memory_func) (address, buffer, INSNLEN, info); > - if (status == 0) > - { > - unsigned long insn; > - if (endianness == BFD_ENDIAN_BIG) > - insn = (unsigned long) bfd_getb32 (buffer); > - else > - insn = (unsigned long) bfd_getl32 (buffer); > - return nios2_disassemble (address, insn, info); > + status = (*info->read_memory_func)(address, buffer, INSNLEN, info); > + if (status == 0) { > + unsigned long insn; > + if (endianness == BFD_ENDIAN_BIG) { > + insn = (unsigned long) bfd_getb32(buffer); > + } else { > + insn = (unsigned long) bfd_getl32(buffer); > + } > + return nios2_disassemble(address, insn, info); > } > > - /* We might have a 16-bit R2 instruction at the end of memory. Try that. */ > - if (info->mach == bfd_mach_nios2r2) > - { > - status = (*info->read_memory_func) (address, buffer, 2, info); > - if (status == 0) > - { > - unsigned long insn; > - if (endianness == BFD_ENDIAN_BIG) > - insn = (unsigned long) bfd_getb16 (buffer); > - else > - insn = (unsigned long) bfd_getl16 (buffer); > - return nios2_disassemble (address, insn, info); > - } > + /* We might have a 16-bit R2 instruction at the end of memory. Try that. */ > + if (info->mach == bfd_mach_nios2r2) { > + status = (*info->read_memory_func)(address, buffer, 2, info); > + if (status == 0) { > + unsigned long insn; > + if (endianness == BFD_ENDIAN_BIG) { > + insn = (unsigned long) bfd_getb16(buffer); > + } else { > + insn = (unsigned long) bfd_getl16(buffer); > + } > + return nios2_disassemble(address, insn, info); > + } > } > > - /* If we got here, we couldn't read anything. */ > - (*info->memory_error_func) (status, address, info); > - return -1; > + /* If we got here, we couldn't read anything. */ > + (*info->memory_error_func)(status, address, info); > + return -1; > } > > /* These two functions are the main entry points, accessed from > Reviewed-by: Laurent Vivier <laurent@vivier.eu>
diff --git a/disas/nios2.c b/disas/nios2.c index c3e82140c79..d124902ae3e 100644 --- a/disas/nios2.c +++ b/disas/nios2.c @@ -3482,38 +3482,37 @@ static int print_insn_nios2 (bfd_vma address, disassemble_info *info, enum bfd_endian endianness) { - bfd_byte buffer[INSNLEN]; - int status; + bfd_byte buffer[INSNLEN]; + int status; - status = (*info->read_memory_func) (address, buffer, INSNLEN, info); - if (status == 0) - { - unsigned long insn; - if (endianness == BFD_ENDIAN_BIG) - insn = (unsigned long) bfd_getb32 (buffer); - else - insn = (unsigned long) bfd_getl32 (buffer); - return nios2_disassemble (address, insn, info); + status = (*info->read_memory_func)(address, buffer, INSNLEN, info); + if (status == 0) { + unsigned long insn; + if (endianness == BFD_ENDIAN_BIG) { + insn = (unsigned long) bfd_getb32(buffer); + } else { + insn = (unsigned long) bfd_getl32(buffer); + } + return nios2_disassemble(address, insn, info); } - /* We might have a 16-bit R2 instruction at the end of memory. Try that. */ - if (info->mach == bfd_mach_nios2r2) - { - status = (*info->read_memory_func) (address, buffer, 2, info); - if (status == 0) - { - unsigned long insn; - if (endianness == BFD_ENDIAN_BIG) - insn = (unsigned long) bfd_getb16 (buffer); - else - insn = (unsigned long) bfd_getl16 (buffer); - return nios2_disassemble (address, insn, info); - } + /* We might have a 16-bit R2 instruction at the end of memory. Try that. */ + if (info->mach == bfd_mach_nios2r2) { + status = (*info->read_memory_func)(address, buffer, 2, info); + if (status == 0) { + unsigned long insn; + if (endianness == BFD_ENDIAN_BIG) { + insn = (unsigned long) bfd_getb16(buffer); + } else { + insn = (unsigned long) bfd_getl16(buffer); + } + return nios2_disassemble(address, insn, info); + } } - /* If we got here, we couldn't read anything. */ - (*info->memory_error_func) (status, address, info); - return -1; + /* If we got here, we couldn't read anything. */ + (*info->memory_error_func)(status, address, info); + return -1; } /* These two functions are the main entry points, accessed from
We are going to modify this function, fix its style first. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- disas/nios2.c | 53 +++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 27 deletions(-)