From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Petr Mladek <pmladek@suse.com>,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
hverkuil@xs4all.nl,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
laurent.pinchart@ideasonboard.com, Joe Perches <joe@perches.com>,
mchehab@kernel.org, linux-media@vger.kernel.org
Subject: Re: [PATCH v4 1/1] lib/vsprintf: Add support for printing V4L2 and DRM fourccs
Date: Tue, 3 Nov 2020 17:46:55 +0200 [thread overview]
Message-ID: <20201103154655.GE4077@smile.fi.intel.com> (raw)
In-Reply-To: <20201103145616.GJ26150@paasikivi.fi.intel.com>
On Tue, Nov 03, 2020 at 04:56:16PM +0200, Sakari Ailus wrote:
> On Tue, Nov 03, 2020 at 04:47:47PM +0200, Andy Shevchenko wrote:
> > On Tue, Nov 03, 2020 at 03:34:00PM +0200, Sakari Ailus wrote:
> > > Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM
> > > pixel formats denoted by fourccs. The fourcc encoding is the same for both
> > > so the same implementation can be used.
...
> > > + char output[sizeof("(xx)(xx)(xx)(xx) little-endian (0x01234567)")];
> >
> > I would add a comment that there is another possibility, i.e. big-endian, but
> > it occupies less space.
>
> This string is here to represent the longest possible output of the
> function. Most of the time it's less. Saying that might make sense but it's
> fairly clear already. Either way works for me though.
It's not known by reading the above line. I would add a comment.
...
> > > + p = special_hex_number(p, output + sizeof(output) - 2, *fourcc,
> > > + sizeof(u32));
> >
> > I would go with one line here.
>
> It's wrapped since the result would be over 80 otherwise.
It will be not the first one breaking the limit in this module for the sake of
readability.
...
> > The (theoretical) problem is here that the case when buffer size is not enough
> > to print a value will be like '(0xabc)' but should be rather '(0xabcd' like
> > snprintf() does in general.
Any comments here?
Perhaps you need to add a comment to explain that the overflow is impossible.
--
With Best Regards,
Andy Shevchenko
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
Petr Mladek <pmladek@suse.com>,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
dri-devel@lists.freedesktop.org, hverkuil@xs4all.nl,
laurent.pinchart@ideasonboard.com, mchehab@kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Joe Perches <joe@perches.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: Re: [PATCH v4 1/1] lib/vsprintf: Add support for printing V4L2 and DRM fourccs
Date: Tue, 3 Nov 2020 17:46:55 +0200 [thread overview]
Message-ID: <20201103154655.GE4077@smile.fi.intel.com> (raw)
In-Reply-To: <20201103145616.GJ26150@paasikivi.fi.intel.com>
On Tue, Nov 03, 2020 at 04:56:16PM +0200, Sakari Ailus wrote:
> On Tue, Nov 03, 2020 at 04:47:47PM +0200, Andy Shevchenko wrote:
> > On Tue, Nov 03, 2020 at 03:34:00PM +0200, Sakari Ailus wrote:
> > > Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM
> > > pixel formats denoted by fourccs. The fourcc encoding is the same for both
> > > so the same implementation can be used.
...
> > > + char output[sizeof("(xx)(xx)(xx)(xx) little-endian (0x01234567)")];
> >
> > I would add a comment that there is another possibility, i.e. big-endian, but
> > it occupies less space.
>
> This string is here to represent the longest possible output of the
> function. Most of the time it's less. Saying that might make sense but it's
> fairly clear already. Either way works for me though.
It's not known by reading the above line. I would add a comment.
...
> > > + p = special_hex_number(p, output + sizeof(output) - 2, *fourcc,
> > > + sizeof(u32));
> >
> > I would go with one line here.
>
> It's wrapped since the result would be over 80 otherwise.
It will be not the first one breaking the limit in this module for the sake of
readability.
...
> > The (theoretical) problem is here that the case when buffer size is not enough
> > to print a value will be like '(0xabc)' but should be rather '(0xabcd' like
> > snprintf() does in general.
Any comments here?
Perhaps you need to add a comment to explain that the overflow is impossible.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2020-11-04 8:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 13:34 [PATCH v4 1/1] lib/vsprintf: Add support for printing V4L2 and DRM fourccs Sakari Ailus
2020-11-03 13:34 ` Sakari Ailus
2020-11-03 14:47 ` Andy Shevchenko
2020-11-03 14:47 ` Andy Shevchenko
2020-11-03 14:56 ` Sakari Ailus
2020-11-03 14:56 ` Sakari Ailus
2020-11-03 15:46 ` Andy Shevchenko [this message]
2020-11-03 15:46 ` Andy Shevchenko
2020-11-03 16:49 ` Joe Perches
2020-11-03 16:49 ` Joe Perches
2020-11-13 10:54 ` Sakari Ailus
2020-11-13 10:54 ` Sakari Ailus
2020-11-13 16:46 ` Joe Perches
2020-11-13 16:46 ` Joe Perches
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=20201103154655.GE4077@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hverkuil@xs4all.nl \
--cc=joe@perches.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mchehab@kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sakari.ailus@linux.intel.com \
--cc=sergey.senozhatsky@gmail.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 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.