From patchwork Fri Jul 1 08:01:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9209499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A042860752 for ; Fri, 1 Jul 2016 08:37:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 912BD2869F for ; Fri, 1 Jul 2016 08:37:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8605C286A1; Fri, 1 Jul 2016 08:37:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 898B9286A0 for ; Fri, 1 Jul 2016 08:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752166AbcGAIhj (ORCPT ); Fri, 1 Jul 2016 04:37:39 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:59967 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751460AbcGAIhf (ORCPT ); Fri, 1 Jul 2016 04:37:35 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9M01GV0MAZJSD0@mailout1.samsung.com>; Fri, 01 Jul 2016 17:01:47 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 4B.63.05161.B6326775; Fri, 1 Jul 2016 17:01:47 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-93-5776236bc02b Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id CB.75.02101.B6326775; Fri, 1 Jul 2016 17:01:47 +0900 (KST) Received: from samsunx.samsung ([10.113.63.54]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O9M00G9YMAVFJA0@mmp2.samsung.com>; Fri, 01 Jul 2016 17:01:47 +0900 (KST) From: Andi Shyti To: Mauro Carvalho Chehab Cc: Joe Perches , Sean Young , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH v2 11/15] [media] lirc_dev: fix variable constant comparisons Date: Fri, 01 Jul 2016 17:01:34 +0900 Message-id: <1467360098-12539-12-git-send-email-andi.shyti@samsung.com> X-Mailer: git-send-email 2.8.1 In-reply-to: <1467360098-12539-1-git-send-email-andi.shyti@samsung.com> References: <1467360098-12539-1-git-send-email-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLLMWRmVeSWpSXmKPExsWyRsSkUDdbuSzc4NozDYvtR56xWiz+8ZzJ Yvb9xywWl3fNYbPo2bCV1WL1swqLhU+/sziwe1xf8onZY8kba48t/XfZPb6susbs0bdlFaPH 501yAWxRXDYpqTmZZalF+nYJXBnrn/SzFMzkqTj86xtLA+NVzi5GTg4JAROJs0t7mSBsMYkL 99azdTFycQgJrGCUWHlsIRNM0Z3Gp8wQiVmMEgf+rIKq+sgosXp7HyNIFZuApkTT7R9ACQ4O EQFjiXM/1EHCzAIHGCV6u11AbGEBX4mlx+ewg9gsAqoSf7Z+YAIp5xVwl1g7tRRil5zE5ekP 2EBsTqDw3Xe7wKYLCbhJzN11jx1krYTAInaJvreXoOYISHybfIgFZI6EgKzEpgPME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AoxlHP5x67i3zXldFT9qfqfT6Z2hm/7xVFcwBd1ku9RBb9YzHfPH5U9 grvWZb8yeyjygP/Qq/tfn91iUCtdwNBhtpQrtFujxepQYfmfsj0a3s3dMiw3Xyy5E9V0ndOw VUt37y+rgMP2f1sVbrbePZr5zmh3/a79VVfuvjxTyRGzPTNob6vSQiWW4oxEQy3mouJEACXI 7km9AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;