Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1821180imm; Sat, 18 Aug 2018 05:17:22 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyfdiWB4MXRVRWWR3OzHPogSnhm60yzotwpdAg2BixaGZK5/C5dD+Ov8DS1fZmBsc60QB+r X-Received: by 2002:a63:d03:: with SMTP id c3-v6mr5695135pgl.322.1534594642275; Sat, 18 Aug 2018 05:17:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534594642; cv=none; d=google.com; s=arc-20160816; b=ZHtO+ENzrsZerQMuK2p3qxvVNXxE3L2HNI3WAEl53rYqwtV3oO5mB8gy70YcoNVfoe WzFYxBuxnFtwRZKMjwjq+9Me3w3Fw5SlLOa6Qnu/A/JGJBvqi/raRCbtKHT8CvQIy9ax DJtWjrtMBxVXC/MKA5ElOUMDr3u3foZ8WBfpHIe6s05moWqvu3iwnGGyB2gzVHZ5Q3EE RecVOqrPPas+5N2iqEvhCx7AN2qT7XSZrpfSfx0fE3xHBkhuH5XTMA1WIVwOtbmcHTbv kPi4vuUYh+qvFkjT4iCf9etN92K5wO/RfpWnhYZDvWPY6WAm4QgBaGeE6XoDGD8stpYS 7OBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=isgBrRhxr1Z015GK2yeX19lTMHexVxpo9sS5kPf91TY=; b=BfA/lxh6AxwJE5NI9WZOlaCnsm8HE3jfVwTcw5pxIGQiaQb+0R/tCgOT1KYTBX8GS0 /ZMfWB/tDEkfbKNxaMKLeaIEQ1gXs2bdIjUtJf27yl3b5NSHH/Rq8JX3kZ4rJvGx6RFu lY20Hm0pG5CRpSdJ7vXzRUg0Cas4MCeI0uXFn9KYTcccbqByPYVsRjFS4d8GYSfJ2ERI zDS6+o7AA7tfRn47BS669+N1OftAAJ7Ryi5DJ5N8vK0HGNx7L8MrjLqbH+UzhKb5jQjE IUYJSxcADhH4k7x/aQ5HgIdoFaJaXUB3a9AzcLUczC5nkDCOMWUvBHWwMfUSQ/50BsXy kevw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10-v6si1392082plr.58.2018.08.18.05.16.54; Sat, 18 Aug 2018 05:17:22 -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; 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 S1726452AbeHRPVd (ORCPT + 99 others); Sat, 18 Aug 2018 11:21:33 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:60245 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726266AbeHRPVd (ORCPT ); Sat, 18 Aug 2018 11:21:33 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A90E273083E21; Sat, 18 Aug 2018 20:13:59 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.399.0; Sat, 18 Aug 2018 20:13:32 +0800 From: zhong jiang To: CC: , , , , , Subject: [PATCH] Coccinelle: remove pci_alloc_consistent semantic to dectect in zalloc-simple.cocci Date: Sat, 18 Aug 2018 20:01:40 +0800 Message-ID: <1534593700-3036-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Because pci_alloc_consistent has been deprecated. We prefer to use dam_alloc_coherent directly. Therefore, we should remove pci_alloc_consistent to increase the confidence. Signed-off-by: zhong jiang --- scripts/coccinelle/api/alloc/zalloc-simple.cocci | 41 +----------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/scripts/coccinelle/api/alloc/zalloc-simple.cocci b/scripts/coccinelle/api/alloc/zalloc-simple.cocci index 92b2091..d819275 100644 --- a/scripts/coccinelle/api/alloc/zalloc-simple.cocci +++ b/scripts/coccinelle/api/alloc/zalloc-simple.cocci @@ -35,8 +35,7 @@ statement S; * x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\| kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\| - devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|pci_alloc_consistent(...,E1,...)\| - kvmalloc_node(E1,...)\); + devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|kvmalloc_node(E1,...)\); if ((x==NULL) || ...) S * memset((T2)x,0,E1); @@ -124,15 +123,6 @@ statement S; - x = (T)kvmalloc(E1,E2); + x = (T)kvzalloc(E1,E2); | -- x = pci_alloc_consistent(E2,E1,E3); -+ x = pci_zalloc_consistent(E2,E1,E3); -| -- x = (T *)pci_alloc_consistent(E2,E1,E3); -+ x = pci_zalloc_consistent(E2,E1,E3); -| -- x = (T)pci_alloc_consistent(E2,E1,E3); -+ x = (T)pci_zalloc_consistent(E2,E1,E3); -| - x = kvmalloc_node(E1,E2,E3); + x = kvzalloc_node(E1,E2,E3); | @@ -389,35 +379,6 @@ msg="WARNING: kvzalloc should be used for %s, instead of kvmalloc/memset" % (x) coccilib.report.print_report(p[0], msg) //----------------------------------------------------------------- -@r8 depends on org || report@ -type T, T2; -expression x; -expression E1,E2,E3; -statement S; -position p; -@@ - - x = (T)pci_alloc_consistent@p(E2,E1,E3); - if ((x==NULL) || ...) S - memset((T2)x,0,E1); - -@script:python depends on org@ -p << r8.p; -x << r8.x; -@@ - -msg="%s" % (x) -msg_safe=msg.replace("[","@(").replace("]",")") -coccilib.org.print_todo(p[0], msg_safe) - -@script:python depends on report@ -p << r8.p; -x << r8.x; -@@ - -msg="WARNING: pci_zalloc_consistent should be used for %s, instead of pci_alloc_consistent/memset" % (x) -coccilib.report.print_report(p[0], msg) -//----------------------------------------------------------------- @r9 depends on org || report@ type T, T2; expression x; -- 1.7.12.4