All of lore.kernel.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Jordan Niethe <jniethe5@gmail.com>
Cc: linuxppc-dev@ozlabs.org, alistair@popple.id.au
Subject: Re: [PATCH 1/4] powerpc: Add a ppc_inst_as_str() helper
Date: Tue, 2 Jun 2020 14:41:33 -0500	[thread overview]
Message-ID: <20200602194133.GT31009@gate.crashing.org> (raw)
In-Reply-To: <20200602052728.18227-1-jniethe5@gmail.com>

On Tue, Jun 02, 2020 at 03:27:25PM +1000, Jordan Niethe wrote:
> There are quite a few places where instructions are printed, this is
> done using a '%x' format specifier. With the introduction of prefixed
> instructions, this does not work well. Currently in these places,
> ppc_inst_val() is used for the value for %x so only the first word of
> prefixed instructions are printed.
> 
> When the instructions are word instructions, only a single word should
> be printed. For prefixed instructions both the prefix and suffix should
> be printed. To accommodate both of these situations, instead of a '%x'
> specifier use '%s' and introduce a helper, __ppc_inst_as_str() which
> returns a char *. The char * __ppc_inst_as_str() returns is buffer that
> is passed to it by the caller.
> 
> It is cumbersome to require every caller of __ppc_inst_as_str() to now
> declare a buffer. To make it more convenient to use __ppc_inst_as_str(),
> wrap it in a macro that uses a compound statement to allocate a buffer
> on the caller's stack before calling it.
> 
> Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>

> +#define PPC_INST_STR_LEN sizeof("0x00000000 0x00000000")

sizeof is not a function or anything function-like; it's just an
operator, like (unary) "+" or "-" or dereference "*".  The parentheses
are completely redundant here.  And it kind of matters, as written a
reader might think that a string object is actually constructed here.

But, so very many people do this, I'm not going to fight this fight ;-)


Segher

  parent reply	other threads:[~2020-06-02 19:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02  5:27 [PATCH 1/4] powerpc: Add a ppc_inst_as_str() helper Jordan Niethe
2020-06-02  5:27 ` [PATCH 2/4] powerpc/xmon: Improve dumping prefixed instructions Jordan Niethe
2020-06-02  5:27 ` [PATCH 3/4] powerpc: Handle prefixed instructions in show_user_instructions() Jordan Niethe
2022-02-22 14:34   ` Christophe Leroy
2022-03-14 23:00     ` Jordan Niethe
2020-06-02  5:27 ` [PATCH 4/4] powerpc: Handle prefixed instructions in show_instructions() Jordan Niethe
2020-06-02  7:43 ` [PATCH 1/4] powerpc: Add a ppc_inst_as_str() helper Joel Stanley
2020-06-02 19:41 ` Segher Boessenkool [this message]
2020-07-24 13:24 ` Michael Ellerman

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=20200602194133.GT31009@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=alistair@popple.id.au \
    --cc=jniethe5@gmail.com \
    --cc=linuxppc-dev@ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.