linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Jonathan Corbet <corbet@lwn.net>,
	John Ogness <john.ogness@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] hexdump: Convert the ascii boolean into a flag variable
Date: Tue, 24 Dec 2024 17:41:47 +0200	[thread overview]
Message-ID: <Z2rWO44BjR52Dorx@smile.fi.intel.com> (raw)
In-Reply-To: <20240826162416.74501-2-miquel.raynal@bootlin.com>

On Mon, Aug 26, 2024 at 06:24:15PM +0200, Miquel Raynal wrote:
> The print_hex_dump() prototype is already quite long and there are
> already several hundred in-tree users. One argument is a boolean for
> enabling the ascii output. This is one way to format the buffer. We
> could think of other ways, which in this case might need other booleans
> to be enabled. In order to avoid messing several times with the
> prototype (and all the callers), let's switch to a 'flags'
> variable which can be easily extended.
> 
> There is no behavioral change intended.

...

>  extern void print_hex_dump(const char *level, const char *prefix_str,
>  			   int prefix_type, int rowsize, int groupsize,
> -			   const void *buf, size_t len, _Bool ascii);
> +			   const void *buf, size_t len,
> +			   unsigned int flags);

Why two lines? It fits perfectly even 80 limit.

...

>  static inline void print_hex_dump(const char *level, const char *prefix_str,
>  				  int prefix_type, int rowsize, int groupsize,
> -				  const void *buf, size_t len, _Bool ascii)
> +				  const void *buf, size_t len,
> +				  unsigned int flags)

Ditto. (And check entire conversion for theses unneeded new lines)

...

>  	print_hex_dump(KERN_ERR, "  ", DUMP_PREFIX_ADDRESS, 16,
> -			1, mpc, mpc->length, 1);
> +			1, mpc, mpc->length, DUMP_FLAG_ASCII);

While at it, I would reformat the code to be wrapped in more logical way, like

	print_hex_dump(KERN_ERR, "  ", DUMP_PREFIX_ADDRESS, 16, 1,
		       mpc, mpc->length, DUMP_FLAG_ASCII);

Also it fixes the broken indentation of the second line.
Same remark to the entire patch where it applies.

...

>  	pr_debug("Virtual Machine Save Area (VMSA):\n");
> -	print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, save, sizeof(*save), false);
> +	print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, save, sizeof(*save),
> +			     0);

Same, why two lines out of a sudden? If code already uses one line and it's
longer than 80, no need to wrap. The cases when it goes over 100 with new flag
name put there would make sense to wrap.

...

>  	if (copy_from_user(buf, (void __user *)(regs->pc & -16), sizeof(buf)) == 0) {
>  		print_hex_dump(KERN_INFO, " ", DUMP_PREFIX_NONE,
> -			       32, 1, buf, sizeof(buf), false);
> +			       32, 1, buf, sizeof(buf), 0);

I would assume you can even use one line now for this, but at bare minumum
"32, 1," part can be moved to the previous line. I dunno how to do this in
coccinelle in automatic way. In _this_ case it can be left as is, as there
is no logical issues (in comparison to one I pointed out above).


-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-12-24 15:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-26 16:24 [PATCH 0/2] hexdump: Allow skipping identical lines Miquel Raynal
2024-08-26 16:24 ` [PATCH 1/2] hexdump: Convert the ascii boolean into a flag variable Miquel Raynal
2024-12-24 15:41   ` Andy Shevchenko [this message]
2024-08-26 16:24 ` [PATCH 2/2] hexdump: Allow skipping identical lines Miquel Raynal
2024-08-26 17:35   ` Andy Shevchenko
2024-08-27  9:13     ` Miquel Raynal
2024-08-27 13:36       ` Andy Shevchenko
2024-08-26 17:32 ` [PATCH 0/2] " Andy Shevchenko
2024-08-27  9:01   ` Miquel Raynal
2024-08-27 13:29     ` Andy Shevchenko
2024-12-24 11:56       ` Miquel Raynal
2024-12-24 15:49         ` Andy Shevchenko
2024-12-30 11:35           ` Miquel Raynal
2025-01-13 12:16             ` Andy Shevchenko

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=Z2rWO44BjR52Dorx@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=john.ogness@linutronix.de \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=miquel.raynal@bootlin.com \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=thomas.petazzoni@bootlin.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).