qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Thomas Huth" <thuth@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	qemu trival <qemu-trivial@nongnu.org>,
	Michael Tokarev <mjt@tls.msk.ru>, QEMU <qemu-devel@nongnu.org>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH 19/29] disas: use QEMU_IS_ALIGNED macro
Date: Sun, 23 Jul 2017 16:52:05 +0200	[thread overview]
Message-ID: <a49428cc-88e9-dbd8-3d2f-207acbef68f9@redhat.com> (raw)
In-Reply-To: <3b25ec9f-5711-de4c-eade-eecef96b6379@redhat.com>

On 18/07/2017 16:43, Thomas Huth wrote:
> On 18.07.2017 13:07, Marc-André Lureau wrote:
>> Hi
>>
>> On Mon, Jul 17, 2017 at 11:09 PM, Philippe Mathieu-Daudé
>> <f4bug@amsat.org> wrote:
>>> Applied using the Coccinelle semantic patch scripts/coccinelle/use_osdep.cocci
> [...]
>>> diff --git a/disas.c b/disas.c
>>> index d335c55bbf..8b59448286 100644
>>> --- a/disas.c
>>> +++ b/disas.c
>>> @@ -151,7 +151,7 @@ static int print_insn_objdump(bfd_vma pc, disassemble_info *info,
>>>      info->read_memory_func(pc, buf, n, info);
>>>
>>>      for (i = 0; i < n; ++i) {
>>> -        if (i % 32 == 0) {
>>> +        if (QEMU_IS_ALIGNED(i, 32)) {
>>>              info->fprintf_func(info->stream, "\n%s: ", prefix);
>>>          }
>>>          info->fprintf_func(info->stream, "%02x", buf[i]);
> 
> This looks wrong to me. QEMU_IS_ALIGNED should be used for addresses and
> similar things. This part here is about pretty printing a hex dump.
> 
> The code should likely be converted to use qemu_hexdump() instead, I guess.

qemu_hexdump only works with FILE*.

But I agree that QEMU_IS_ALIGNED looks weird here.  I think it should
mostly be used when the argument is a pointer, to hide the cast.  Uses
for non-pointer arguments should be decided on a one-by-one basis; "is
the first argument an address" is definitely a good thing to consider.
Another might be "is the second argument a variable", because "i % n ==
0" is less efficient than "(i & (n - 1)) == 0".

Paolo


Paolo


  reply	other threads:[~2017-07-23 14:52 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18  6:09 [Qemu-trivial] [PATCH 00/29] coccinelle script to enforce qemu/osdep.h macros usage Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 01/29] coccinelle: add a " Philippe Mathieu-Daudé
2017-07-18 15:18   ` Eric Blake
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 02/29] pci: remove superfluous parenthesis Philippe Mathieu-Daudé
2017-07-19  0:16   ` [Qemu-trivial] [Qemu-devel] " Richard Henderson
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 03/29] qemu-img: use QEMU_IS_ALIGNED macro Philippe Mathieu-Daudé
2017-07-18 15:19   ` Eric Blake
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 04/29] scsi-disk: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 05/29] block: " Philippe Mathieu-Daudé
2017-07-18  9:59   ` Juan Quintela
2017-07-18 15:25   ` Eric Blake
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 06/29] migration/block: " Philippe Mathieu-Daudé
2017-07-18  9:58   ` Juan Quintela
2017-07-18 11:19     ` [Qemu-trivial] [Qemu-devel] " Alex Bennée
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 07/29] ds1338: " Philippe Mathieu-Daudé
2017-07-18 10:23   ` Alastair D'Silva
2017-07-18 13:23     ` Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 08/29] ui: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 09/29] net: " Philippe Mathieu-Daudé
2017-07-18 17:51   ` Eric Blake
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 10/29] net/rocker: " Philippe Mathieu-Daudé
2017-07-18 17:51   ` Eric Blake
2017-07-21 16:23     ` Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 11/29] s390x/sclp: " Philippe Mathieu-Daudé
2017-07-18  9:58   ` Cornelia Huck
2017-07-18 10:03     ` Cornelia Huck
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 12/29] sm501: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 13/29] tcg: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 14/29] cris: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 16/29] lm32: " Philippe Mathieu-Daudé
2017-07-18 11:42   ` Michael Walle
2017-07-18 14:37     ` [Qemu-trivial] [Qemu-devel] " Thomas Huth
2017-07-21 16:29       ` Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 18/29] nios2: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 19/29] disas: " Philippe Mathieu-Daudé
2017-07-18 11:07   ` [Qemu-trivial] [Qemu-devel] " Marc-André Lureau
2017-07-18 14:43     ` Thomas Huth
2017-07-23 14:52       ` Paolo Bonzini [this message]
2017-07-24 12:16         ` Eric Blake
2017-07-18 11:09   ` [Qemu-trivial] " Michael Tokarev
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 20/29] disas: use ARRAY_SIZE macro Philippe Mathieu-Daudé
2017-07-18  6:49   ` David Gibson
2017-07-18 10:55   ` [Qemu-trivial] [Qemu-devel] " Marc-André Lureau
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 21/29] qga: " Philippe Mathieu-Daudé
2017-07-18 11:29   ` [Qemu-trivial] [Qemu-devel] " Marc-André Lureau
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 22/29] vmsvga: " Philippe Mathieu-Daudé
2017-07-18 11:28   ` [Qemu-trivial] [Qemu-devel] " Marc-André Lureau
2017-07-18  6:09 ` [Qemu-trivial] [PATCH 23/29] async: " Philippe Mathieu-Daudé
2017-07-18 10:54   ` [Qemu-trivial] [Qemu-devel] " Marc-André Lureau
2017-07-18  6:10 ` [Qemu-trivial] [PATCH 24/29] tests/acpi: " Philippe Mathieu-Daudé
2017-07-18  6:10 ` [Qemu-trivial] [PATCH 25/29] libqos: " Philippe Mathieu-Daudé
2017-07-18 11:00   ` [Qemu-trivial] [Qemu-devel] " Marc-André Lureau
2017-07-18 11:58   ` [Qemu-trivial] " Laurent Vivier
2017-07-18 13:36     ` Philippe Mathieu-Daudé
2017-07-18  6:10 ` [Qemu-trivial] [PATCH 26/29] tests/tcg: " Philippe Mathieu-Daudé
2017-07-18 10:56   ` [Qemu-trivial] [Qemu-devel] " Marc-André Lureau
2017-07-18 11:16     ` Alex Bennée
2017-07-18 11:24       ` Marc-André Lureau
2017-07-18 13:52         ` Alex Bennée
2017-07-18 13:41       ` Philippe Mathieu-Daudé
2017-07-18  6:10 ` [Qemu-trivial] [PATCH 27/29] tests/hbitmap: " Philippe Mathieu-Daudé
2017-07-18 10:52   ` [Qemu-trivial] [Qemu-devel] " Marc-André Lureau
2017-07-18 15:36   ` John Snow
2017-07-18  6:10 ` [Qemu-trivial] [PATCH 28/29] tests/qapi: use QEMU_IS_ALIGNED macro Philippe Mathieu-Daudé
2017-07-18 10:53   ` [Qemu-trivial] [Qemu-devel] " Marc-André Lureau
2017-07-18  6:10 ` [Qemu-trivial] [PATCH 29/29] tests/qapi: use ARRAY_SIZE macro Philippe Mathieu-Daudé
2017-07-18 10:52   ` [Qemu-trivial] [Qemu-devel] " Marc-André Lureau
     [not found] ` <20170718061005.29518-16-f4bug@amsat.org>
2017-07-18 11:08   ` [Qemu-trivial] [Qemu-devel] [PATCH 15/29] microblaze: use QEMU_IS_ALIGNED macro Marc-André Lureau
2017-07-18 14:46     ` Thomas Huth

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=a49428cc-88e9-dbd8-3d2f-207acbef68f9@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=marcandre.lureau@gmail.com \
    --cc=mjt@tls.msk.ru \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.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;
as well as URLs for NNTP newsgroup(s).