Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1435154

[PATCH v2 11/15] [media] lirc_dev: fix variable constant comparisons

From Andi Shyti <andi.shyti@samsung.com>
Newsgroups linux.kernel
Subject [PATCH v2 11/15] [media] lirc_dev: fix variable constant comparisons
Date 2016-07-01 10:40 +0200
Message-ID <rQ29s-4m1-29@gated-at.bofh.it> (permalink)
References <rQ1Gp-4bf-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


When comparing a variable with a constant, the comparison should
start from the variable and not from the constant. It's also
written in the human DNA.

Swap the terms of comparisons whenever the constant comes first
and fix the following checkpatch warning:

  WARNING: Comparisons should place the constant on the right side of the test

Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
 drivers/media/rc/lirc_dev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index 16cca46..689e369 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -246,13 +246,13 @@ static int lirc_allocate_driver(struct lirc_driver *d)
 		return -EINVAL;
 	}
 
-	if (MAX_IRCTL_DEVICES <= d->minor) {
+	if (d->minor >= MAX_IRCTL_DEVICES) {
 		dev_err(d->dev, "minor must be between 0 and %d!\n",
 						MAX_IRCTL_DEVICES - 1);
 		return -EBADRQC;
 	}
 
-	if (1 > d->code_length || (BUFLEN * 8) < d->code_length) {
+	if (d->code_length < 1 || d->code_length > (BUFLEN * 8)) {
 		dev_err(d->dev, "code length must be less than %d bits\n",
 								BUFLEN * 8);
 		return -EBADRQC;
@@ -283,7 +283,7 @@ static int lirc_allocate_driver(struct lirc_driver *d)
 		for (minor = 0; minor < MAX_IRCTL_DEVICES; minor++)
 			if (!irctls[minor])
 				break;
-		if (MAX_IRCTL_DEVICES == minor) {
+		if (minor == MAX_IRCTL_DEVICES) {
 			dev_err(d->dev, "no free slots for drivers!\n");
 			err = -ENOMEM;
 			goto out_lock;
-- 
2.8.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 00/15] lirc_dev fixes and beautification Andi Shyti <andi.shyti@samsung.com> - 2016-07-01 10:20 +0200
  [PATCH v2 14/15] [media] lirc_dev: fix potential segfault Andi Shyti <andi.shyti@samsung.com> - 2016-07-01 10:30 +0200
  [PATCH v2 02/15] [media] lirc_dev: allow bufferless driver registration Andi Shyti <andi.shyti@samsung.com> - 2016-07-01 10:30 +0200
    Re: [PATCH v2 02/15] [media] lirc_dev: allow bufferless driver  registration Sean Young <sean@mess.org> - 2016-07-02 19:20 +0200
  [PATCH v2 12/15] [media] lirc_dev: fix error return value Andi Shyti <andi.shyti@samsung.com> - 2016-07-01 10:40 +0200
    Re: [PATCH v2 12/15] [media] lirc_dev: fix error return value Hans Verkuil <hverkuil@xs4all.nl> - 2016-07-04 13:50 +0200
  [PATCH v2 11/15] [media] lirc_dev: fix variable constant comparisons Andi Shyti <andi.shyti@samsung.com> - 2016-07-01 10:40 +0200
  [PATCH v2 09/15] [media] lirc_dev: merge three if statements in only  one Andi Shyti <andi.shyti@samsung.com> - 2016-07-01 11:20 +0200

csiph-web