From patchwork Wed Jul 6 09:01:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9215905 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 4707560467 for ; Wed, 6 Jul 2016 09:45:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35650287D1 for ; Wed, 6 Jul 2016 09:45:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 279D9287DB; Wed, 6 Jul 2016 09:45:07 +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 A8B3A287D1 for ; Wed, 6 Jul 2016 09:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752418AbcGFJoz (ORCPT ); Wed, 6 Jul 2016 05:44:55 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:56504 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753189AbcGFJoF (ORCPT ); Wed, 6 Jul 2016 05:44:05 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9W01QH60D6JV60@mailout2.samsung.com>; Wed, 06 Jul 2016 18:43:54 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 1E.69.05161.AD2DC775; Wed, 6 Jul 2016 18:43:54 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-3d-577cd2daeec2 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 67.12.02101.AD2DC775; Wed, 6 Jul 2016 18:43:54 +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 <0O9W003BE0D2J600@mmp2.samsung.com>; Wed, 06 Jul 2016 18:43:53 +0900 (KST) From: Andi Shyti To: Mauro Carvalho Chehab Cc: Joe Perches , Sean Young , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH v3 11/15] [media] lirc_dev: fix variable constant comparisons Date: Wed, 06 Jul 2016 18:01:23 +0900 Message-id: <1467795687-10737-12-git-send-email-andi.shyti@samsung.com> X-Mailer: git-send-email 2.8.1 In-reply-to: <1467795687-10737-1-git-send-email-andi.shyti@samsung.com> References: <1467795687-10737-1-git-send-email-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRmVeSWpSXmKPExsWyRsSkUPfWpZpwgwndAhbbjzxjtVj84zmT xanJz5gsZt9/zGJxedccNoueDVtZLVY/q7BY+PQ7iwOHx/Uln5g9lryx9tjSf5fd48uqa8we fVtWMXp83iTncerrZ/YA9igum5TUnMyy1CJ9uwSujD+rn7AVzOSp6FvVytzAeJWzi5GTQ0LA RGL7zFksELaYxIV769m6GLk4hARWMEps23mTGaZo5pIZrBCJWYwST39+ZYdwPjJK/Fp2kwmk ik1AU6Lp9g+gdg4OEQFjiXM/1EFqmAWeMkrsmzqXCSQuLOArseWFDUg5i4CqxOnOxWALeAXc Je5vewO1TE7i8vQHYGM4geJXlyuBhIUE3CT2b7sJtlZCYBu7xNEdu1kg5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ChATSE0tSs1NTC1KLYPqYODilGhhDTSZunTX5k+W1jtOh+j5KH79E//u4a/d+xd3/ +T//uXZ53VX3fxxTpe2Cpyse3XhHddMc/7RQky8PeFg/bduYXytjvqkkWuh237eLWy9J6Xw+ 13jg4gvv/ccjtBjtKkyrvr7sXzlxY6TlqrZeQX/hypuvT974M2td/kzH3h6T3NvrfCbprNPa o8RSnJFoqMVcVJwIAIDSWhLHAgAA 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 09bdd69..c2b32e0 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -245,13 +245,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; @@ -282,7 +282,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;