From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, tomi.valkeinen@ideasonboard.com,
bingbu.cao@intel.com
Subject: Re: [PATCH 3/3] media: uapi: Use unsigned int values for assigning bits in u32 fields
Date: Mon, 8 May 2023 10:52:09 +0300 [thread overview]
Message-ID: <20230508075209.GV23514@pendragon.ideasonboard.com> (raw)
In-Reply-To: <ZFidqGx5Kl/moD6h@kekkonen.localdomain>
Hi Sakari,
On Mon, May 08, 2023 at 09:58:48AM +0300, Sakari Ailus wrote:
> On Mon, May 08, 2023 at 09:30:23AM +0300, Laurent Pinchart wrote:
> > On Mon, May 08, 2023 at 09:19:24AM +0300, Sakari Ailus wrote:
> > > On Sat, May 06, 2023 at 02:32:23PM +0300, Laurent Pinchart wrote:
> > > > On Fri, May 05, 2023 at 11:51:01PM +0300, Sakari Ailus wrote:
> > > > > Use unsigned int values annoted by "U" for u32 fields. While this is a
> > > > > good practice, there doesn't appear to be a bug that this patch would fix.
> > > > >
> > > > > The patch has been generated using the following command:
> > > > >
> > > > > perl -i -pe 's/\([0-9]+\K <</U <</g' -- include/uapi/linux/media.h
> > > >
> > > > How about using the _BITUL() macro from include/uapi/linux/const.h ?
> > >
> > > These are u32 whereas _BITUL makes an unsigned long. Int (as in U) is 32
> > > bits on all platforms where Linux is used AFAIK.
> >
> > I know, but is it a problem ?
>
> If we have a u32 field, unsigned int is the right type for that (from
> non-fixed length C types), not unsigned long. In practice it would work, I
> have no doubts about that. The compiler could still do different decisions
> due to this, promoting values to a 64-bits for instance.
>
> If we had _BITU(), I'd be happy to use that. :-)
Note how BIT() is defined in include/vdso/bits.h:
#include <vdso/const.h>
#define BIT(nr) (UL(1) << (nr))
And in include/vdso/const.h:
#include <uapi/linux/const.h>
#define UL(x) (_UL(x))
BIT() is thus essentially identical to _BITUL(). As we use the former
everywhere without any trouble, I wouldn't expect issue with the latter.
> How about this: let's merge this patch and then see how a _BITU() macro
> would fare.
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2023-05-08 7:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 20:50 [PATCH 0/3] Random cleanups Sakari Ailus
2023-05-05 20:50 ` [PATCH 1/3] media: mc: Make media_get_pad_index() use pad type flag Sakari Ailus
2023-05-06 11:25 ` Laurent Pinchart
2023-05-05 20:51 ` [PATCH 2/3] media: Documentation: Rename meta format files Sakari Ailus
2023-05-06 11:25 ` Laurent Pinchart
2023-05-05 20:51 ` [PATCH 3/3] media: uapi: Use unsigned int values for assigning bits in u32 fields Sakari Ailus
2023-05-06 11:32 ` Laurent Pinchart
2023-05-08 6:19 ` Sakari Ailus
2023-05-08 6:30 ` Laurent Pinchart
2023-05-08 6:58 ` Sakari Ailus
2023-05-08 7:52 ` Laurent Pinchart [this message]
2023-05-08 8:34 ` Sakari Ailus
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=20230508075209.GV23514@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=bingbu.cao@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tomi.valkeinen@ideasonboard.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