From: Segher Boessenkool <segher@kernel.crashing.org>
To: Thomas Huth <thuth@redhat.com>
Cc: Dinar valeev <k0da@opensuse.org>,
aik@ozlabs.ru, linuxppc-dev@ozlabs.org, slof@lists.ozlabs.org,
Dinar Valeev <dvaleev@suse.com>,
nikunj@linux.vnet.ibm.com
Subject: Re: [PATCH v2] Caps in not always shift
Date: Thu, 9 Jul 2015 07:59:16 -0500 [thread overview]
Message-ID: <20150709125916.GA2990@gate.crashing.org> (raw)
In-Reply-To: <20150709080048.1fda0d0f@thh440s>
On Thu, Jul 09, 2015 at 08:00:48AM +0200, Thomas Huth wrote:
> > /**
> > + * Checks if keypos is a latin key
> > + * @param keypos
> > + * @return -
> > + */
> > +void check_latin(uint8_t keypos)
> > + if (keypos > KEYP_LATIN_A || keypos < KEYP_LATIN_Z) {
> > + return true;
> > + } else {
> > + return false;
> > + }
> > +
>
> That does not look like valid C to me ... "void" return type and
> returning true or false ...
Valid C90, not valid C99 or C11. Any sane compiler will warn in any
case :-)
> and what about the outermost curly braces?
Yeah, this doesn't compile at all.
> Anyway, you could even write this much more simple without if-statement
> instead:
>
> bool check_latin(uint8_t keypos)
> {
> return keypos > KEYP_LATIN_A || keypos < KEYP_LATIN_Z;
> }
It's a pretty bad name, "check" doesn't give an indication of what the
polarity of the return value is.
I would expect something more like
bool is_latin(uint8_t keypos)
{
return keypos >= KEYP_LATIN_A && keypos <= KEYP_LATIN_Z;
}
or
bool is_not_latin(uint8_t keypos)
{
return keypos < KEYP_LATIN_A || keypos > KEYP_LATIN_Z;
}
The proposed code would always return true?
Segher
next prev parent reply other threads:[~2015-07-09 12:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 16:47 [PATCH v2] Caps in not always shift Dinar valeev
2015-07-09 6:00 ` Thomas Huth
2015-07-09 12:59 ` Segher Boessenkool [this message]
2015-07-10 6:42 ` Paul Mackerras
2015-07-13 10:11 ` Dinar Valeev
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=20150709125916.GA2990@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=aik@ozlabs.ru \
--cc=dvaleev@suse.com \
--cc=k0da@opensuse.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=nikunj@linux.vnet.ibm.com \
--cc=slof@lists.ozlabs.org \
--cc=thuth@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 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.