Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1541860ybl; Fri, 10 Jan 2020 21:09:14 -0800 (PST) X-Google-Smtp-Source: APXvYqwZauEcZbvsVKgiL9t5XjsReeYwbnywoE4oFWUcHf8xwsc90WpNgW/iHqb6XUIv6RD79mdw X-Received: by 2002:a05:6830:1608:: with SMTP id g8mr5401934otr.169.1578719354049; Fri, 10 Jan 2020 21:09:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578719354; cv=none; d=google.com; s=arc-20160816; b=gauUxMgZN8slVV0P3K1m1vPU2+cJM2lN8CnZc38O8HMrH0+Kd/LZko78QJ0k3xwE03 FSiTNDJbOyy45KuYPvLBUSWjLKkJ9NZvfGTu42HpLPlvIdbJZ9EPxxmPVNnGgjiKvlBP MJc6iEFuqzIn79T0sgwAcZuuGhfXvQ0y0ckjhDIt0Mf21Vdq028KxOKwpec0pGzoAh0+ RFr7bGoi7ZIreM0zc727V2M3G/WcicfP18bLL48e+givR9zuYET7yPcelJjSVI9gympq NAxrfiAo1ngZHhY1LDKUKq7q9qAeIgWwnJOQAwS39RPUAEpZEtYU2jVtKAnySKBd5cjx PLjQ== 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:from:references:cc:to:subject; bh=AbPu8Ezh4wGNcBZDqC5I1a5QOyFBx7dTmXKc6IOROOI=; b=XIh2v75hJ+rWgnYUISEnZ8HhHLTPmhp+/Y24jJYr2f4ttSO9vZboY6MO7AmR9kSQ8d G8Nnbd52lGZE3lPXBVtTaZQan6eF3W+luRJlhGVZWKoh/tasjdLvfGrCAHqG//DWCQJA q54k7o+QYb3CnDxTLy9e6z0NkgZQF82h3cr/WH/Y90+uWBFqI5H9OWgNHzAkQgtjR60s A6BKHuYntscPm+Rw1l9AYFzF5TgzpvD7hVQrPs+MJbcBMkSzlyP36JeVsNUIjBYMAIMx CmC7nbS7DEtg7Ba76ZmpWuQYKQuC1dMJA9sqWkrn9HMnsjzFQ5EwL61hYlC6LMl6e/bn ngxg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7si2874759otp.284.2020.01.10.21.08.59; Fri, 10 Jan 2020 21:09:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726037AbgAKFGn (ORCPT + 99 others); Sat, 11 Jan 2020 00:06:43 -0500 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:37793 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725816AbgAKFGn (ORCPT ); Sat, 11 Jan 2020 00:06:43 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R311e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07486;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0TnNYIC5_1578719194; Received: from IT-C02W23QPG8WN.local(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0TnNYIC5_1578719194) by smtp.aliyun-inc.com(127.0.0.1); Sat, 11 Jan 2020 13:06:39 +0800 Subject: Re: [PATCH v3] coccinelle: semantic patch to check for inappropriate do_div() calls To: Markus Elfring , cocci@systeme.lip6.fr, kernel-janitors@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Gilles Muller , Greg Kroah-Hartman , Julia Lawall , Masahiro Yamada , =?UTF-8?Q?Matthias_M=c3=a4nnich?= , Michal Marek , Nicolas Palix , Thomas Gleixner References: <20200110131526.60180-1-wenyang@linux.alibaba.com> <91abb141-57b8-7659-25ec-8080e290d846@web.de> From: Wen Yang Message-ID: Date: Sat, 11 Jan 2020 13:06:34 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <91abb141-57b8-7659-25ec-8080e290d846@web.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/1/11 12:35 上午, Markus Elfring wrote: >> +@initialize:python@ > … >> +def filter_out_safe_constants(str): > … >> +def construct_warnings(str, suggested_fun): > > * I suggest once more to adjust the dependency specifications for the usage > of these functions by SmPL rules. > Most of the functions here are for all operation modes. > * Can the local variable “msg” be omitted? > > >> +coccilib.org.print_todo(p[0], construct_warnings("div64_ul")) > > I suggest again to move the prefix “div64_” into the string literal > of the function implementation. > “div64_ul” indicates the function name we recommend. As shown in the patch: +def construct_warnings(suggested_fun): + msg="WARNING: do_div() does a 64-by-32 division, please consider using %s instead." + return msg % suggested_fun ... +coccilib.org.print_todo(p[0], construct_warnings("div64_ul")) If we delete the prefix "div64_", it may reduce readability. > > The SmPL code for two disjunctions could become shorter. > You may suggest to modify it as follows: +@@ +*do_div(f, \( l \| ul \| ul64 \| sl64 \) ); We agree with Julia: I don't se any point to this. The code matched will be the same in both cases. The original code is quite readable, without the ugly \( etc. -- Regards, Wen > Regards, > Markus >