Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp317679ybp; Thu, 10 Oct 2019 18:54:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUbaQZigy3uNMOKF3R1Qba04nUE1LRjS0Q2BOWgCInBjHBHnRnKq6nHZIYvOhVQuZk7f6N X-Received: by 2002:a05:6402:68b:: with SMTP id f11mr10883422edy.173.1570758859796; Thu, 10 Oct 2019 18:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570758859; cv=none; d=google.com; s=arc-20160816; b=fKZE25GdMZ4gYgR2ZH29lz46h/v2ECyLQcpl+oD6FW6hZY+X8Z8ezAsSyhLkIDx42u MYMiHzMLma5rCUeIDr3XyMsSEdX8nFn8FNVpEH7t0qS6IxrrSD5CtKTSge6eRHCChBf1 FKAYo5zUWSbqNrW33pONSXBu/TP7GAXOpPl9MhYrFEF751CVMI5aKC8XZzZX3rp3SkO4 +jUzMgz7D33EQX7SnSAwm3qAvOhr+hr9Lo4HJjHupSjuvJfAiusV1B16u6Vn42cqrwu2 3wTABStNbkq2hDvCnTP5babUIoZN/aPZ8RAIsjexkkEcIKoiZZH2tEnsMi1du4O/OZ0G TTRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=0D9kDWFAtk322Iw2N8/OoCkWVljQqtRC6srP+BJypzs=; b=UkGMvkzgrjbHtY+KCWSeikJ3KOjLVqw0dPR8oDZv5AU1kP89q4OP7rDT2J9y9y/l9K uXjGrKzPG/ffP3sFSIGAz7OROiEezOXukYfw+16NEv7xRNlf01s9feug6f+/rnv1vU1z mQsrCKFuPdDom8pScOAN/c/SQ+gI3lYr0Xe3dAkDH7cHnLaGiq7Pvbb2kZdAFEMNBKqQ tCBjBTn9icvghuHqaJoYb56V7ob/WXM2Ls95mJe+sFwCKL3B+Ubc7qtJtbtRET/4LhPI q+i/7lICTCTsBxiz19SPIOJwVVOMMUIJ8UgvVQergsb6PZUGzK+2J4kmQB69uG3tOoXA si3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eE4slVkd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si4196581ejb.42.2019.10.10.18.53.55; Thu, 10 Oct 2019 18:54:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eE4slVkd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727905AbfJKBwe (ORCPT + 99 others); Thu, 10 Oct 2019 21:52:34 -0400 Received: from mail-pf1-f174.google.com ([209.85.210.174]:33224 "EHLO mail-pf1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727588AbfJKBwd (ORCPT ); Thu, 10 Oct 2019 21:52:33 -0400 Received: by mail-pf1-f174.google.com with SMTP id q10so5097669pfl.0 for ; Thu, 10 Oct 2019 18:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=0D9kDWFAtk322Iw2N8/OoCkWVljQqtRC6srP+BJypzs=; b=eE4slVkd/xAN7grlQNv6VFKdnXV965x+0gZEyh3+6J32wyYZA9pqFlaVRKIiOGYzYz uzyor5dTSo/pJbQW66TniwPjtbgv+znbv5Kz2oGyzS4OS0QbWQogqlWen76A50acddxL o4p2hfyi8La+uyMoJfXl8KwlCfgnIQyr/WEq0SHx3h0j1IqMywhHU2X/T5xv7LTaDYav MWjMcCpBdpbH8iXlJMRPHU4nWu47AUWdWw110ufN/K/1xmgMT3cJ3Mw46V60+dMKojXL lKg5yWq973OWE1Qay/Q0u7oOkyL6IiMkG5r43SEOvWxa59DKmkhNzjpP2g+4jaUIwRfT PGIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=0D9kDWFAtk322Iw2N8/OoCkWVljQqtRC6srP+BJypzs=; b=Rl5Fygb8vzN1Y3wkGDI+3HEGRMAp7tVc1d4l+daH8j5RLzh6ILoN/wtCbmX3Yv5eMX ShlsQhLdYc7eyHMCQVV/uSh+GXiyTWt/2qC/xi85pC4pg8rGZCve7O4VoO1XPixtb0c7 ZXxJtESvdjk9KutbiEzpc5oJvxI/fRIcviaD5kGRhjZHlpxdFE2G8b8Tm3RmuEF+CXR1 lkF/Wdcrpiu+vqBU1d0XITt/O9ZQydFbZ9rdrm0k22Xen4QvkIKxgGbfTjNbJWfFdT/2 dR90R17XqsRUAn3Og1YRf6c3qRfRKbliykz50zaVccVe0TGZLWZqwpRRrX34g1TApxxq zVBw== X-Gm-Message-State: APjAAAVauTn/ITzp89AmAtK/BQHbrcImvxNoNl47y+S30qMaBWAC0CdN pq+BScc/zdhywmGauPsX/Mk= X-Received: by 2002:a62:ee01:: with SMTP id e1mr13956221pfi.3.1570758751626; Thu, 10 Oct 2019 18:52:31 -0700 (PDT) Received: from localhost ([2001:e60:3034:6131:3055:27ff:fe5a:5b5c]) by smtp.gmail.com with ESMTPSA id h1sm6546486pfk.124.2019.10.10.18.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 18:52:30 -0700 (PDT) Date: Fri, 11 Oct 2019 10:52:25 +0900 From: Sergey Senozhatsky To: Joe Perches Cc: Sergey Senozhatsky , linux-kernel@vger.kernel.org Subject: checkpatch: comparisons with a constant on the left Message-ID: <20191011015225.GA27495@jagdpanzerIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joe, I noticed that this code #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) triggers checkpatch's warning: "WARNING: Comparisons should place the constant on the right side of the test" Both LINUX_VERSION_CODE and KERNEL_VERSION are constants, so I'm wondering if it's worth it to improve that check a tiny bit. E.g. something utterly trivial: --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index cf7543a9d1b2..8a1964c3d9a5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4855,6 +4855,7 @@ sub process { my $to = $4; my $newcomp = $comp; if ($lead !~ /(?:$Operators|\.)\s*$/ && + $to !~ /^KERNEL_VERSION.*/ && $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ && WARN("CONSTANT_COMPARISON", "Comparisons should place the constant on the right side of the test\n" . $herecurr) && --- I'm sure you'll have a better idea. -ss