[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YCGmD1d1Zn+EhrDH@smile.fi.intel.com>
Date: Mon, 8 Feb 2021 22:58:55 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Sakari Ailus <sakari.ailus@...ux.intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux Media Mailing List <linux-media@...r.kernel.org>,
Petr Mladek <pmladek@...e.com>,
Dave Stevenson <dave.stevenson@...pberrypi.com>,
dri-devel <dri-devel@...ts.freedesktop.org>,
Hans Verkuil <hverkuil@...all.nl>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Joe Perches <joe@...ches.com>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>
Subject: Re: [PATCH v6 1/3] lib/vsprintf: Add support for printing V4L2 and
DRM fourccs
On Mon, Feb 08, 2021 at 10:43:30PM +0200, Andy Shevchenko wrote:
> On Mon, Feb 8, 2021 at 10:11 PM Sakari Ailus
> <sakari.ailus@...ux.intel.com> wrote:
...
> > +static noinline_for_stack
> > +char *fourcc_string(char *buf, char *end, const u32 *fourcc,
> > + struct printf_spec spec, const char *fmt)
> > +{
>
> > + char output[sizeof("(xx)(xx)(xx)(xx) little-endian (0x01234567)")];
>
> Do we have any evidence / document / standard that the above format is
> what people would find good? From existing practices (I consider other
> printings elsewhere and users in this series) I find '(xx)' form for
> hex numbers is weird. The standard practice is to use \xHH (without
> parentheses).
> > + val = *fourcc & ~BIT(31);
> > +
> > + for (i = 0; i < sizeof(*fourcc); i++) {
> > + unsigned char c = val >> (i * 8);
>
> ...
>
> > + /* Weed out spaces */
> > + if (c == ' ')
> > + continue;
>
> None of the existing users does that. Why?
>
> > + /* Print non-control ASCII characters as-is */
> > + if (isascii(c) && isprint(c)) {
> > + *p++ = c;
> > + continue;
> > + }
> > +
> > + *p++ = '(';
> > + p = hex_byte_pack(p, c);
> > + *p++ = ')';
> > + }
To be on constructive side, I would propose to replace above with something
like:
__le32 val;
val = cpu_to_le32(*fourcc & ~BIT(31));
p += string_escape_mem(&val, sizeof(*fourcc), output, sizeof(output), ESCAPE_NP | ESCAPE_HEX, NULL);
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists