lkml.org 
[lkml]   [2020]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/1] lib/vsprintf: Add support for printing V4L2 and DRM fourccs
On Fri, Apr 03, 2020 at 12:11:56PM +0300, Sakari Ailus wrote:
> Add a printk modifier %ppf (for pixel format) for printing V4L2 and DRM
> pixel formats denoted by 4ccs. The 4cc encoding is the same for both so
> the same implementation can be used.

...

> +static noinline_for_stack
> +char *fourcc_string(char *buf, char *end, const u32 *fourcc,
> + struct printf_spec spec, const char *fmt)
> +{

> +#define FOURCC_STRING_BE "-BE"
> + char s[sizeof(*fourcc) + sizeof(FOURCC_STRING_BE)] = { 0 };

I guess it makes it too complicated.

char s[8];

> + if (check_pointer(&buf, end, fourcc, spec))
> + return buf;
> +
> + if (fmt[1] != 'c' || fmt[2] != 'c')
> + return error_string(buf, end, "(%p4?)", spec);
> +

> + put_unaligned_le32(*fourcc & ~BIT(31), s);

Can you elaborate what the difference in output with this bit set over cleared?
I.o.w. why don't we need to put it as BE and for LE case addd "-LE"?

> + if (*fourcc & BIT(31))
> + strscpy(s + sizeof(*fourcc), FOURCC_STRING_BE,
> + sizeof(FOURCC_STRING_BE));

We know the size, and we may put '\0' as well
if (*fourcc & BIT(31))
strscpy(&s[4], "-BE", sizeof("-BE"));
else
strscpy(&s[4], "", sizeof(""));


> + return string(buf, end, s, spec);
> +}

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2020-04-03 11:31    [W:0.787 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site