From patchwork Thu Mar 16 14:22:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Garver X-Patchwork-Id: 739839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vkW003qdNz9rvt for ; Fri, 17 Mar 2017 01:22:40 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 40668B1E; Thu, 16 Mar 2017 14:22:37 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 2CA8CA88 for ; Thu, 16 Mar 2017 14:22:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7F9221ED for ; Thu, 16 Mar 2017 14:22:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 28DC7437F75 for ; Thu, 16 Mar 2017 14:22:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 28DC7437F75 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=erig.me Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=e@erig.me DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 28DC7437F75 Received: from wsfd-netdev-buildsys.ntdv.lab.eng.bos.redhat.com (wsfd-netdev-buildsys.ntdv.lab.eng.bos.redhat.com [10.19.17.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE30260319; Thu, 16 Mar 2017 14:22:34 +0000 (UTC) From: Eric Garver To: dev@openvswitch.org Date: Thu, 16 Mar 2017 10:22:32 -0400 Message-Id: <20170316142232.25959-1-e@erig.me> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 16 Mar 2017 14:22:35 +0000 (UTC) X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] checkpatch.py: Fix false positive on if/when/for X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org We need to use == instead of the is operator. If you're unlucky it may fail because they're not exactly the same object, but hold the same value. Example false positive: E(120): Inappropriate bracing around statement + if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING]) Fixes: 30c7ffd5ac46 ("utilities/checkpatch.py: Check for appropriate bracing") Signed-off-by: Eric Garver --- utilities/checkpatch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index dfe6f9c7621e..638ac97746b6 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -144,11 +144,11 @@ def if_and_for_end_with_bracket_check(line): """This is a rather naive counter - it won't deal with quotes""" balance = 0 for letter in line: - if letter is '(': + if letter == '(': balance += 1 - elif letter is ')': + elif letter == ')': balance -= 1 - return balance is 0 + return balance == 0 if __regex_is_for_if_single_line_bracket.search(line) is not None: if not balanced_parens(line):