Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1081588ybe; Thu, 5 Sep 2019 10:01:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKaXNQlDhpGMBwMPBEqMYb42HehSPIIymOBpf5LHpRQTgBtN+AecFWBUb945/o/Ps8XL/N X-Received: by 2002:a62:5cc2:: with SMTP id q185mr4893510pfb.221.1567702908875; Thu, 05 Sep 2019 10:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567702908; cv=none; d=google.com; s=arc-20160816; b=CBqB03Z/v9TnR1uf/Znb2yKp0UGcBzvfCJTEwWVVuAp/bhBA3jmfJzRTZjZu7P6YR3 JtdWbcvD0XIlhUIsjNAkjtyqN96TxmjVznx6qIzU6hTxT6dIJ8exGVsv8PLwIlt0eMc6 VhDA4dOtcpm36sSwkAiRlfwylnbVTf2fIYW+m9vb48m/AtczOedacLn0fwCzIMAYHS8V JNlDANjy0cg5MGcGZfK37vSGke8BWqsI4iAqMfRgNoMtIXqNcVgycMApR5FY9b74GDBM dyBzk1lVIGWHaToP8qa8oPJ2dpIO4aUW8OLQHEf1i/91UNvsiBQE69q5Lc2hqeoi5jv+ mYSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:to:autocrypt:from:subject:references:cc:dkim-signature; bh=wiKT8u1doIBeZ6Ys3RFXVY/3gCgEeYiLhtIaz2EY51U=; b=jNjbwNlhEUPGFMQUcsunxG8N1BPDzVn2/MCorOTbXXmIRVKnhgUpD7tnG48H1Vcm3+ Prven74gKOw/PC7oVapNLddILuO5AmOl916XLYJPpCPun49sONTAURvLf1QeMGjdNYlO Q18a5dbs8MIL/c0vZsDy3wwlLPEOsZsbsik+iRzJMxC900wLO63A7l3NOULI5L8yYVdM n5BVb/Zq4SC6BOg77Kzql9ivQVLa8mWQ5a26F2Log1n1JWi9SERYStZuueX9iyqhaNs1 cDGi1CGPQuIucmZJ/hkZ/N3i4b4j/4BQgwJsJRj6FVzBsZgOiK9jbz2jGL0urHZxJHQF 39yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@web.de header.s=dbaedf251592 header.b=e99iYp1P; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si2563892pjp.78.2019.09.05.10.01.31; Thu, 05 Sep 2019 10:01:48 -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=@web.de header.s=dbaedf251592 header.b=e99iYp1P; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732554AbfIEMdN (ORCPT + 99 others); Thu, 5 Sep 2019 08:33:13 -0400 Received: from mout.web.de ([217.72.192.78]:57205 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731438AbfIEMdM (ORCPT ); Thu, 5 Sep 2019 08:33:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1567686777; bh=XfQXB2vIZe2JukTJVFUwHi4vpiAorDqzVl4iR6s4MU8=; h=X-UI-Sender-Class:Cc:References:Subject:From:To:Date:In-Reply-To; b=e99iYp1PbHtyxwKkP1vcOOeJMfVbmpSk9zTCP3MqIF9mxIGuTPyI5C1aF7tdJhUof gF5f/dHMI0Zhj4iDKnpy69ytMpmJlJ0/rOEcKdIEnUrJnvu/WhU+udDyYWkk8JjWwf hUpyfYxssvM/8e4CBa3dqELJRtAGRKKvQLjNp1/M= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.1.2] ([78.49.131.221]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M5x3d-1iLD60023N-00xovn; Thu, 05 Sep 2019 14:32:57 +0200 Cc: linux-kernel@vger.kernel.org, Gilles Muller , Julia Lawall , Masahiro Yamada , Michal Marek , Nicolas Palix References: <20190904221223.5281-1-efremov@linux.com> Subject: Re: [RFC PATCH] coccinelle: check for integer overflow in binary search From: Markus Elfring Autocrypt: addr=Markus.Elfring@web.de; prefer-encrypt=mutual; keydata= mQINBFg2+xABEADBJW2hoUoFXVFWTeKbqqif8VjszdMkriilx90WB5c0ddWQX14h6w5bT/A8 +v43YoGpDNyhgA0w9CEhuwfZrE91GocMtjLO67TAc2i2nxMc/FJRDI0OemO4VJ9RwID6ltwt mpVJgXGKkNJ1ey+QOXouzlErVvE2fRh+KXXN1Q7fSmTJlAW9XJYHS3BDHb0uRpymRSX3O+E2 lA87C7R8qAigPDZi6Z7UmwIA83ZMKXQ5stA0lhPyYgQcM7fh7V4ZYhnR0I5/qkUoxKpqaYLp YHBczVP+Zx/zHOM0KQphOMbU7X3c1pmMruoe6ti9uZzqZSLsF+NKXFEPBS665tQr66HJvZvY GMDlntZFAZ6xQvCC1r3MGoxEC1tuEa24vPCC9RZ9wk2sY5Csbva0WwYv3WKRZZBv8eIhGMxs rcpeGShRFyZ/0BYO53wZAPV1pEhGLLxd8eLN/nEWjJE0ejakPC1H/mt5F+yQBJAzz9JzbToU 5jKLu0SugNI18MspJut8AiA1M44CIWrNHXvWsQ+nnBKHDHHYZu7MoXlOmB32ndsfPthR3GSv jN7YD4Ad724H8fhRijmC1+RpuSce7w2JLj5cYj4MlccmNb8YUxsE8brY2WkXQYS8Ivse39MX BE66MQN0r5DQ6oqgoJ4gHIVBUv/ZwgcmUNS5gQkNCFA0dWXznQARAQABtCZNYXJrdXMgRW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xJhbzN+r9djSGGN/5IBDfUqSANC8cWzHpWaHmSuU3JSAMB/N+yQjIad2ztTckZY pwT6oxng29LzZspTYUEzMz3wK2jQHw+U66qBFk8whA7B2uAU1QdGyPgahLYSOa4XAEGb6wbI FEE= To: Denis Efremov , cocci@systeme.lip6.fr, kernel-janitors@vger.kernel.org Message-ID: <8f454c56-735c-0620-ead4-b59e328b0283@web.de> Date: Thu, 5 Sep 2019 14:32:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.0 MIME-Version: 1.0 In-Reply-To: <20190904221223.5281-1-efremov@linux.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:ZXkurD9h48YNUpH2sA9zXRQ7s8GTYYE8Wv1K0E1TnIYYk7loz1a eb9BGhjNIRwZVsqYEgXUKmhGxxBYAITOtev0+g6zR9a5VBLM9ofY9SAGCSeL+tr8ytvGdtR aDkHqgvR6Z16WXFR91LoTQNvHfHkkZhkiobhwYYGHvSUaGNIe1ju2NWm7/vGLUWjPNlB30Q bo97IAYqVs+LM2RxjF9fw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:UAQlLQyjxKU=:00X0gjPswzSxNVfINMEUe/ xGHfGxJ9+mKqN9BXiNLmZ4RHTIza8BTZsig2AbNuVLp2z6lD+n8hT/iNTXHwOIYjsPkF9258c FKUwKUyCgi4PHgnfjy7aDC1Kgs9AkUyFZdhvL2w5nXd+2P4kCCq6gBsm+E1mHYmc+vYm+ep5L gDyv77K0+DYybDX582sUV7qsBOLCE5sv8ixW+6Ht2H7TzCNvaMhfUUkUv7r4woGT3pNNcer7d bP2NcTXSSKRHjahqOlS5dfk0lXhPC05s4SMnREU+/c3TDH/+1mG4B1xhuAIu59tG5TGE00ru3 4ryS0y38aXTfzUyvPXkrlYZ8D68CObPW8XQixRpihmTmzaKQQFPMJ2Jj54M0G91Le+d040upq 38yhupY1G32D9MI9wBbBx/xJNkcdylcuFSh7OoiF90nRgzB7tVoYHGhi/Oq9yDGcJMFonAbeY G/lPVGB63I9NwBH7Wzj7mnqBdeTqQICNCj/ZtzUSEFtxhtGhouvDqfhMHScj8kD8LQcpy7kBZ egXWORYq8q/QgiZKLHCduePGcAqUtXwsHf+wolj6YBRMlYLkrJSNvYV/V2c1vuyn3qG5mH/HN BylPvUHiDY95TGwMc7iaUa7NQWVk8ZwX1vRF9u9y2MFeM0ZZ4dkIolflgRegTMO9aipYOaDWP /JpL+NueMgWHoBr3dYbwOu2m+RyGCmqiKevEfoY41aM+iqqKYXlz3on2LrgTVdFg2bYkv5KOm I5/RHfdLtLpS6dxndYyuVii3X0VArRoeQkwWSm/aK5jqu7mV0wnyNwg9E/vlYaAmN/3ckZeTm SRmnCdqEQmpKGLWG3A+uh8dOw5gHOxoRkrIusIxBV+37dF8fU4NcfxaBHkQSZYITNewW/TMci lR7xkmVSFUbChtAjvhaUNT/LUf6Hnv0Ki6MZpg0FylkMqEAVDGOmsp7sxlued+DDNYXyPWL3M 8ln8oBfN91yQZukEhbcRvnaZLdH0Y2RyvtIECYIEteaKzkfA7ssDhBk6dY2rPnB1N6o85aUYv STlQJQHB0G3d4ZDKU0bF172mkig96yplMM1n5p9qUlYOl3ABn2CSn2VOX1+3811kqFbRH5uWk V3Ptcef/M66Q04w35xhFrjz7ezavlG+dBUaSaRA9hRlRbDwdjiNXCMQdKn0UDJq+xaJl9qyQK Zs5LgTPvLeuGsK4NRxT5DkPyhl3qXuVeaPUXciM673lwTeVpma0c7Ou5/ymOs4S9wiAOa53qt NvdkDqmDT52h+Y0kk Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +identifier l, h, m; Can expressions make sense for these metavariables? > +@@ > +( > + while (\(l < h\|l <=3D h\|(h - l) > 1\|(l + 1) < h\|l < (h - 1)\)) { > + ... > +( > + ((l + h)@p / c) > +| > + ((l + h)@p >> c) > +) > + ... > + } * I suggest again to look at further possibilities to reduce undesirable code duplication also together with the usage of SmPL disjunctions. * The condition specification might be easier to read with a few additional spaces (or the following variant). * The SmPL ellipses will probably need further considerations. +@@ +( + while ( +( l \( < \| <=3D \) h +| (h - l) > 1 +| (h - 1) > l +| (l + 1) < h +) ) + { + <+... + ((l + h)@p \( / \| >> \) c) + ...+> + } > +@script:python depends on report@ > +p << r.p; > +@@ > + > +msg=3D"WARNING: custom implementation of bsearch is error-prone. " > +msg+=3D"Consider using lib/bsearch.c or fix the midpoint calculation " > +msg+=3D"as 'm =3D l + (h - l) / 2;' to prevent the arithmetic overflow.= " > +coccilib.report.print_report(p[0], msg) The Linux coding style supports to put a long string literal also into a s= ingle line. Thus I find such a message construction nicer without the extra variable = =E2=80=9Cmsg=E2=80=9D. Regards, Markus