Received: by 10.223.176.5 with SMTP id f5csp1954738wra; Thu, 8 Feb 2018 06:17:04 -0800 (PST) X-Google-Smtp-Source: AH8x226eVpLxkV4NpUqeuMmvdSJpDzyuumN1YSDa0zfDSShBED27Zgkc1GDKT6zCuknPuHDej3Pc X-Received: by 10.101.64.67 with SMTP id h3mr663043pgp.168.1518099424283; Thu, 08 Feb 2018 06:17:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518099424; cv=none; d=google.com; s=arc-20160816; b=SQupeRJjxMstyJ9TLx+QZskf09OpjrjE0BxKpOtEFL9FVshYJlTbWXnQivRiOS00mT et0VLPjp/SjcFAaeqJ5nbNh0ME1vuBjj35DDIEGExQ4d7DXJN+686+6lq4loNpzH+e+G IMLGbIbUp13wyqC8/nLo17AltWsiRbGHedxUMdujDP6eblNqdmIiFdbF98b2aud0++Ai ElOATFqpptYLmxuxw3SBpZmzKbj58fnCLu16Imj4qczwLzFwJ/OSR+zUX3eFvAzh0OzF V8PltXnlYc8wUn7qXXjRe6jT2fx0M4L4Ku0l+hBPRDKusnoOcOnrmrseXhnCOQJlvG9m 2IvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=bFVhpV2RIbnax2cSf2EnDD7TwTHI20uzpzFyjmVczvU=; b=tWyMl0BSjANSXjVKh+C2CGoKOl0nNDiM1HGmNeQVwK11nJWKVbwGUcUknW0gvJph4j L/pOucHf96o16lqlCo3k/z2MaihTkPO7zw0k1gKtn1y7FzqvnyEgH5jzrb+XQJ9Zd9OU LpcAvDGm2wQg4rLr1xbrSi4a+K1J8gIMf8eMgp7b48SNtz1gH6JCjz1sY0Nll7LxjO5H OlNGdHxyaK7qsU1fg423bX6cLMB6p/tyA6JQFeoFPMMlmvqvLieKhD6aSYx2eABN+VLq +iif7D3rN6aZGD/b1JeoCTf19w4laBhit0nyF7FhmdfKPB8s9jyFEF3Lle4OsEaShVF0 Ekqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=SA9VOgv5; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n79si18705pfa.148.2018.02.08.06.16.50; Thu, 08 Feb 2018 06:17:04 -0800 (PST) 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=@oracle.com header.s=corp-2017-10-26 header.b=SA9VOgv5; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752192AbeBHOOx (ORCPT + 99 others); Thu, 8 Feb 2018 09:14:53 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:35166 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751788AbeBHOOv (ORCPT ); Thu, 8 Feb 2018 09:14:51 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w18EBxtl003812; Thu, 8 Feb 2018 14:14:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=bFVhpV2RIbnax2cSf2EnDD7TwTHI20uzpzFyjmVczvU=; b=SA9VOgv5wcRpR376vhtagkRaSBc6yYkG5Z8W4NSwieXfTZXKxRDXgurTV7webFYWORuU IlQUjIYE3osGIZLWAYL4o+rVJ8nRFIb/vA06RR8eGR2mufsYRLX/VjnZZ2mxeVwLJq0v qrUeIUziET5EKYj35RYEXHDRNSP/EWVZzceNOfe8+1putaN6RXqJtYtt0cJ09BOOc0h7 nmvx7wyNS+/o5+gZttn/VnrRIMR3v7wr7KSsSdcTyPucX9ErG+t5R95e0XracmFfGBJ6 3jOSI9zp4ZzqNGJTs+CX32c5YdQCL/h3ZRma0EeqJBMfDE14bOUS/CwL9DE/h7JiXWgp LQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2g0r2x8139-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2018 14:14:36 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w18E4juU022956 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 8 Feb 2018 14:04:46 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w18E4in7009905; Thu, 8 Feb 2018 14:04:44 GMT Received: from mwanda (/197.254.35.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Feb 2018 06:04:43 -0800 Date: Thu, 8 Feb 2018 17:04:35 +0300 From: Dan Carpenter To: Julia Lawall Cc: Masahiro Yamada , Wolfram Sang , kernel-janitors@vger.kernel.org, Gilles Muller , Nicolas Palix , Michal Marek , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: Re: [PATCH] scripts/coccinelle/misc/shift.cocci: detect < or > that should be a shift Message-ID: <20180208140435.drxepn4badqj76sr@mwanda> References: <1518094434-12852-1-git-send-email-Julia.Lawall@lip6.fr> <20180208135350.e4yljburdpq7f5ny@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8798 signatures=668663 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802080166 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 08, 2018 at 02:58:56PM +0100, Julia Lawall wrote: > > > On Thu, 8 Feb 2018, Dan Carpenter wrote: > > > On Thu, Feb 08, 2018 at 01:53:54PM +0100, Julia Lawall wrote: > > > This checks for a comparison using < or > between two constants, > > > considering both explicit constants (1, 2, etc) and macros defined > > > with #define. False positives are possible in the latter case, when > > > a macro may have multiple possible definitions and it is indeed > > > necessary to check the value. There are currently two such false > > > positives, in drivers/net/ethernet/chelsio/cxgb3/sge.c: > > > > > > q->fl[0].use_pages = FL0_PG_CHUNK_SIZE > 0; > > > q->fl[1].use_pages = FL1_PG_CHUNK_SIZE > 0; > > > > > > > We could eliminate both these false postives by ignoring >> vs >. Did > > searching for > actually find any bugs? I think you were right that > > right shifting a constant is way less common than left shifting and I > > have some smatch scripts where I ignore right shifting bugs. > > > > On the other hand, two false positives are not a big deal. > > I found no bugs with > at the moment. I figured that the person could > have just as easily written 0 < FL0_PG_CHUNK_SIZE, so it was not worth ^^^^^^^^^^^^^^^^^^^^^ That's a Yoda speak type condition though so it's less common. Unrelated, but I fixed a Yoda condition today where the test was reversed so I feel like Yoda conditions are more likely to be buggy (because they are hard to read). regards, dan carpenter