From: "Alastair D'Silva" <alastair@d-silva.org>
To: 'Petr Mladek' <pmladek@suse.com>
Cc: 'Alastair D'Silva' <alastair@au1.ibm.com>,
'Jani Nikula' <jani.nikula@linux.intel.com>,
'Joonas Lahtinen' <joonas.lahtinen@linux.intel.com>,
'Rodrigo Vivi' <rodrigo.vivi@intel.com>,
'David Airlie' <airlied@linux.ie>,
'Daniel Vetter' <daniel@ffwll.ch>,
'Karsten Keil' <isdn@linux-pingi.de>,
'Jassi Brar' <jassisinghbrar@gmail.com>,
'Tom Lendacky' <thomas.lendacky@amd.com>,
"'David S. Miller'" <davem@davemloft.net>,
'Jose Abreu' <Jose.Abreu@synopsys.com>,
'Kalle Valo' <kvalo@codeaurora.org>,
'Stanislaw Gruszka' <sgruszka@redhat.com>,
'Benson Leung' <bleung@chromium.org>,
'Enric Balletbo i Serra' <enric.balletbo@collabora.com>,
"'James E.J. Bottomley'" <jejb@linux.ibm.com>,
"'Martin K. Petersen'" <martin.petersen@oracle.com>
Subject: RE: [PATCH 2/4] lib/hexdump.c: Optionally suppress lines of filler bytes
Date: Mon, 15 Apr 2019 20:33:47 +1000 [thread overview]
Message-ID: <0db001d4f376$b598af80$20ca0e80$@d-silva.org> (raw)
In-Reply-To: <20190415091812.s4e5zlwldbe62ego@pathway.suse.cz>
> > > On Wed 2019-04-10 13:17:18, Alastair D'Silva wrote:
> > > > From: Alastair D'Silva <alastair@d-silva.org>
> > > >
> > > > Some buffers may only be partially filled with useful data, while
> > > > the rest is padded (typically with 0x00 or 0xff).
> > > >
> > > > This patch introduces flags which allow lines of padding bytes to
> > > > be suppressed, making the output easier to interpret:
> > > > HEXDUMP_SUPPRESS_0X00, HEXDUMP_SUPPRESS_0XFF
> > > >
> > > > The first and last lines are not suppressed by default, so the
> > > > function always outputs something. This behaviour can be further
> > > > controlled with the HEXDUMP_SUPPRESS_FIRST &
> > > HEXDUMP_SUPPRESS_LAST flags.
> > > >
> > > > An inline wrapper function is provided for backwards compatibility
> > > > with existing code, which maintains the original behaviour.
> > > >
> > >
> > > > diff --git a/lib/hexdump.c b/lib/hexdump.c index
> > > > b8a164814744..2f3bafb55a44 100644
> > > > --- a/lib/hexdump.c
> > > > +++ b/lib/hexdump.c
> > > > +void print_hex_dump_ext(const char *level, const char *prefix_str,
> > > > + int prefix_type, int rowsize, int groupsize,
> > > > + const void *buf, size_t len, u64 flags)
> > > > {
> > > > const u8 *ptr = buf;
> > > > - int i, linelen, remaining = len;
> > > > + int i, remaining = len;
> > > > unsigned char linebuf[64 * 3 + 2 + 64 + 1];
> > > > + bool first_line = true;
> > > >
> > > > if (rowsize != 16 && rowsize != 32 && rowsize != 64)
> > > > rowsize = 16;
> > > >
> > > > for (i = 0; i < len; i += rowsize) {
> > > > - linelen = min(remaining, rowsize);
> > > > + bool skip = false;
> > > > + int linelen = min(remaining, rowsize);
> > > > +
> > > > remaining -= rowsize;
> > > >
> > > > + if (flags & HEXDUMP_SUPPRESS_0X00)
> > > > + skip = buf_is_all(ptr + i, linelen, 0x00);
> > > > +
> > > > + if (!skip && (flags & HEXDUMP_SUPPRESS_0XFF))
> > > > + skip = buf_is_all(ptr + i, linelen, 0xff);
> > > > +
> > > > + if (first_line && !(flags & HEXDUMP_SUPPRESS_FIRST))
> > > > + skip = false;
> > > > +
> > > > + if (remaining <= 0 && !(flags &
HEXDUMP_SUPPRESS_LAST))
> > > > + skip = false;
> > > > +
> > > > + if (skip)
> > > > + continue;
> > >
> > > IMHO, quietly skipping lines could cause a lot of confusion,
> > > espcially
> > when the address is not printed.
> > >
> > It's up to the caller to decide how they want it displayed.
>
> I wonder who would want to quietly skip some data values.
> Are you using it yourself? Could you please provide an example?
Yes, but I don't have the content with me at the moment, so I can't share
it. I'm dumping persistent memory labels, which are 64kB long, but only the
first few hundred bytes are populated.
> I do not see why we would need to complicate the API and code by this.
>
> The behavior proposed by Tvrtko Ursulin makes much more sense. I mean
> https://lkml.kernel.org/r/929244ed-cc7f-b0f3-b5ac-
> 50e798e83188@linux.intel.com
I agree that is better, I'll add that to V2.
--
Alastair D'Silva mob: 0423 762 819
skype: alastair_dsilva msn: alastair@d-silva.org
blog: http://alastair.d-silva.org Twitter: @EvilDeece
next prev parent reply other threads:[~2019-04-15 10:33 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-10 3:17 [PATCH 0/4] Hexdump enhancements Alastair D'Silva
2019-04-10 3:17 ` [PATCH 1/4] lib/hexdump.c: Allow 64 bytes per line Alastair D'Silva
2019-04-12 13:48 ` Petr Mladek
2019-04-12 23:22 ` Alastair D'Silva
2019-04-15 9:02 ` Petr Mladek
2019-04-15 10:29 ` Alastair D'Silva
2019-04-15 10:56 ` David Laight
2019-04-15 10:59 ` Alastair D'Silva
[not found] ` <20190410031720.11067-1-alastair-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
2019-04-10 3:17 ` [PATCH 2/4] lib/hexdump.c: Optionally suppress lines of filler bytes Alastair D'Silva
2019-04-10 3:32 ` Alastair D'Silva
2019-04-12 14:03 ` Petr Mladek
2019-04-12 23:28 ` Alastair D'Silva
2019-04-15 9:18 ` Petr Mladek
2019-04-15 10:33 ` Alastair D'Silva [this message]
2019-04-10 3:17 ` [PATCH 3/4] lib/hexdump.c: Replace ascii bool in hex_dump_to_buffer with flags Alastair D'Silva
2019-04-10 6:56 ` Dan Carpenter
2019-04-12 14:12 ` Petr Mladek
2019-04-12 23:31 ` Alastair D'Silva
2019-04-15 9:24 ` Petr Mladek
2019-04-15 10:07 ` Alastair D'Silva
2019-04-15 10:20 ` David Laight
2019-04-15 10:44 ` Alastair D'Silva
2019-04-15 11:03 ` David Laight
2019-04-15 11:12 ` Alastair D'Silva
2019-04-12 14:47 ` Tvrtko Ursulin
2019-04-10 3:17 ` [PATCH 4/4] lib/hexdump.c: Allow multiple groups to be separated by lines '|' Alastair D'Silva
2019-04-10 8:45 ` David Laight
2019-04-10 9:52 ` Alastair D'Silva
2019-04-10 8:53 ` Sergey Senozhatsky
2019-04-10 17:53 ` ✗ Fi.CI.CHECKPATCH: warning for Hexdump enhancements Patchwork
2019-04-10 18:17 ` ✓ Fi.CI.BAT: success " Patchwork
2019-04-11 3:22 ` ✓ Fi.CI.IGT: " Patchwork
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='0db001d4f376$b598af80$20ca0e80$@d-silva.org' \
--to=alastair@d-silva.org \
--cc=Jose.Abreu@synopsys.com \
--cc=airlied@linux.ie \
--cc=alastair@au1.ibm.com \
--cc=bleung@chromium.org \
--cc=daniel@ffwll.ch \
--cc=davem@davemloft.net \
--cc=enric.balletbo@collabora.com \
--cc=isdn@linux-pingi.de \
--cc=jani.nikula@linux.intel.com \
--cc=jassisinghbrar@gmail.com \
--cc=jejb@linux.ibm.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kvalo@codeaurora.org \
--cc=martin.petersen@oracle.com \
--cc=pmladek@suse.com \
--cc=rodrigo.vivi@intel.com \
--cc=sgruszka@redhat.com \
--cc=thomas.lendacky@amd.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