From: "andriy.shevchenko@linux.intel.com" <andriy.shevchenko@linux.intel.com>
To: Aditya Garg <gargaditya08@live.com>
Cc: "pmladek@suse.com" <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
"senozhatsky@chromium.org" <senozhatsky@chromium.org>,
"corbet@lwn.net" <corbet@lwn.net>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"apw@canonical.com" <apw@canonical.com>,
"joe@perches.com" <joe@perches.com>,
"dwaipayanray1@gmail.com" <dwaipayanray1@gmail.com>,
"lukas.bulwahn@gmail.com" <lukas.bulwahn@gmail.com>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Hector Martin <marcan@marcan.st>,
"sven@svenpeter.dev" <sven@svenpeter.dev>,
Janne Grunau <j@jannau.net>,
"alyssa@rosenzweig.io" <alyssa@rosenzweig.io>,
"asahi@lists.linux.dev" <asahi@lists.linux.dev>
Subject: Re: [PATCH v4] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc
Date: Fri, 28 Feb 2025 14:17:42 +0200 [thread overview]
Message-ID: <Z8GpZo3M_QSJo2ka@smile.fi.intel.com> (raw)
In-Reply-To: <PN3PR01MB9597D1584C472757EB9F9C26B8CD2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
On Thu, Feb 27, 2025 at 06:58:24PM +0000, Aditya Garg wrote:
> > On 27 Feb 2025, at 10:40 PM, Aditya Garg <gargaditya08@live.com> wrote:
> >>> On 27 Feb 2025, at 8:13 PM, andriy.shevchenko@linux.intel.com wrote:
> >>> On Thu, Feb 27, 2025 at 06:30:48AM +0000, Aditya Garg wrote:
...
> >>> + switch (fmt[2]) {
> >>> + case 'h':
> >>> + val = orig;
> >>> + break;
> >>> + case 'r':
> >>> + orig = swab32(orig);
> >>> + val = orig;
> >>> + break;
> >>> + case 'l':
> >>> + orig = (__force u32)cpu_to_le32(orig);
> >>> + val = orig;
> >>> + break;
> >>> + case 'b':
> >>> + orig = (__force u32)cpu_to_be32(orig);
> >>> + val = orig;
> >>> + break;
> >>> + case 'c':
> >>> + /* Pixel formats are printed LSB-first */
> >>> + val = swab32(orig & ~BIT(31));
> >>> + pixel_fmt = true;
> >>> + break;
> >>> + default:
> >>> + return error_string(buf, end, "(%p4?)", spec);
> >>> + }
> >>
> >> Actually you can replace all these orig copies by introducing a new boolean, pixel_be.
> >>
> >> Will become
> >>
> >> switch (fmt[2]) {
> >> case 'h':
> >> val = orig;
> >> break;
> >> case 'r': // or 'n' ?
> >> val = swab32(orig);
> >> break;
> >> case 'l':
> >> val = (__force u32)cpu_to_le32(orig);
> >> break;
> >> case 'b':
> >> val = (__force u32)cpu_to_be32(orig);
> >> break;
> >> case 'c':
> >> pixel_fmt = true;
> >> pixel_be = orig & BIT(31);
> >> /* Pixel formats are printed LSB-first */
> >> val = swab32(orig & ~BIT(31));
> >> break;
> >> default:
> >> return error_string(buf, end, "(%p4?)", spec);
> >> }
> >>
> >> And with this the existence of 'val' now becomes doubtful, we may reuse 'orig',
> >> just name it 'val' everywhere, no?
> >
> > In case c, val != orig, in rest it is. We can just use pixel_fmt to check this condition, but places where we use orig, and not val will need an if statement or something similar. Tbh, it's an unecessary complication. You might want to see this part of the code:
>
> More easier IMO can be:
>
> val = pixel_fmt ? swab32(orig & ~BIT(31)) : orig;
>
> At the end of the table
Also will work for me. Just think about it, i.e. how to make code shorter and
still readable.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-02-28 12:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-27 6:30 [PATCH v4] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc Aditya Garg
2025-02-27 14:43 ` andriy.shevchenko
2025-02-27 17:10 ` Aditya Garg
2025-02-27 18:58 ` Aditya Garg
2025-02-28 12:17 ` andriy.shevchenko [this message]
2025-02-28 12:16 ` andriy.shevchenko
2025-02-28 14:09 ` Aditya Garg
2025-02-28 15:03 ` Steven Rostedt
2025-02-28 15:59 ` Petr Mladek
2025-02-28 16:23 ` Aditya Garg
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=Z8GpZo3M_QSJo2ka@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=alyssa@rosenzweig.io \
--cc=apw@canonical.com \
--cc=asahi@lists.linux.dev \
--cc=corbet@lwn.net \
--cc=dwaipayanray1@gmail.com \
--cc=gargaditya08@live.com \
--cc=j@jannau.net \
--cc=joe@perches.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=lukas.bulwahn@gmail.com \
--cc=marcan@marcan.st \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=sven@svenpeter.dev \
/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.