From: Sean Young <sean@mess.org>
To: "David Härdeman" <david@hardeman.nu>
Cc: linux-media@vger.kernel.org, mchehab@redhat.com
Subject: Re: [PATCH] rc-core: add separate defines for protocol bitmaps and numbers
Date: Fri, 19 Oct 2012 11:17:04 +0100 [thread overview]
Message-ID: <20121019101703.GA20317@pequod.mess.org> (raw)
In-Reply-To: <20121018215921.GA18904@hardeman.nu>
On Thu, Oct 18, 2012 at 11:59:21PM +0200, David Härdeman wrote:
> On Wed, Oct 17, 2012 at 05:18:56PM +0100, Sean Young wrote:
> >On Fri, Oct 12, 2012 at 01:11:54AM +0200, David Härdeman wrote:
> >> The RC_TYPE_* defines are currently used both where a single protocol is
> >> expected and where a bitmap of protocols is expected. This patch tries
> >> to separate the two in preparation for the following patches.
> >
> >I'm not sure why this is needed.
>
> I'm not sure I can explain it much better.
>
> Something like rc_keydown() or functions which add/remove entries to the
> keytable want a single protocol. Future userspace APIs would also
> benefit from numeric protocols (rather than bitmap ones). Keytables are
> smaller if they can use a small(ish) integer rather than a bitmap.
>
> Other functions or struct members (e.g. allowed_protos,
> enabled_protocols, etc) accept multiple protocols and need a bitmap.
>
> Using different types reduces the risk of programmer error. Using a
> protocol enum whereever possible also makes for a more future-proof
> user-space API as we don't need to worry about a sufficient number of
> bits being available (e.g. in structs used for ioctl() calls).
>
> The use of both a number and a corresponding bit is dalso one in e.g.
> the input subsystem as well (see all the references to set/clear bit when
> changing keytables for example).
>
> >
> >> The intended use is also clearer to anyone reading the code. Where a
> >> single protocol is expected, enum rc_type is used, where one or more
> >> protocol(s) are expected, something like u64 is used.
> >
> >Having two sets of #define and enums for the same information is not
> >necessarily clearer.
>
> Not only two set of define and enum, two different data types. To me it
> helps a lot to be able to tell from a function declaration whether it
> expects *a* protocol or protocols.
Right, thanks for elaborating. Makes sense.
Sean
next prev parent reply other threads:[~2012-10-19 10:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-11 23:11 [PATCH] rc-core: add separate defines for protocol bitmaps and numbers David Härdeman
2012-10-17 16:18 ` Sean Young
2012-10-18 21:59 ` David Härdeman
2012-10-19 10:17 ` Sean Young [this message]
2012-12-17 15:15 ` James Hogan
2013-01-01 14:34 ` David Härdeman
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=20121019101703.GA20317@pequod.mess.org \
--to=sean@mess.org \
--cc=david@hardeman.nu \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.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