Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1432759AbdDYSLh (ORCPT ); Tue, 25 Apr 2017 14:11:37 -0400 Received: from mailrelay105.isp.belgacom.be ([195.238.20.132]:26620 "EHLO mailrelay105.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1432731AbdDYSLU (ORCPT ); Tue, 25 Apr 2017 14:11:20 -0400 X-Belgacom-Dynamic: yes IronPort-PHdr: =?us-ascii?q?9a23=3AmLUy+BSauwhwDn3hWxSa+Fp559psv+yvbD5Q0YIu?= =?us-ascii?q?jvd0So/mwa67bRCN2/xhgRfzUJnB7Loc0qyN7PCmBDRIyK3CmU5BWaQEbwUCh8?= =?us-ascii?q?QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnY6Uy/yPgtt?= =?us-ascii?q?J+nzBpWaz4Huj7jzqNXvZFBqmT68aPtWJQq/qQGZ4usLhYprbII41RLNplNMev?= =?us-ascii?q?wIg21ycwG9hRH5s+m59p9q9Wx+of8t+tRBWqayK6oxR7JwFzc3NW0posfm40qQ?= =?us-ascii?q?BTCT72cRBz1F2iFDBBLIuVSjBs/8?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2D+AQCckP9Y/zfGs1tbHQwGGAYMgkBrg?= =?us-ascii?q?W2Ob5ElAZU6gg+GJIQWQBgBAQEBAQEBAQEBAWoogjMEAR0BBIMYI4EaJBOKDxG?= =?us-ascii?q?sa4QQh0KGU4FdjVUFnUGSeQ2RV5QZHziBBkMdGIRdAQuCRT41h2eBTwEBAQ?= X-IPAS-Result: =?us-ascii?q?A2D+AQCckP9Y/zfGs1tbHQwGGAYMgkBrgW2Ob5ElAZU6gg+?= =?us-ascii?q?GJIQWQBgBAQEBAQEBAQEBAWoogjMEAR0BBIMYI4EaJBOKDxGsa4QQh0KGU4Fdj?= =?us-ascii?q?VUFnUGSeQ2RV5QZHziBBkMdGIRdAQuCRT41h2eBTwEBAQ?= From: Fabian Frederick To: Julia Lawall Cc: Gilles Muller , cocci@systeme.lip6.fr, Jan Kara , linux-kernel@vger.kernel.org, fabf@skynet.be Subject: [PATCH 1/1 linux-next] scripts/coccinelle/misc: Warn about NULL check on kmap() Date: Tue, 25 Apr 2017 20:11:16 +0200 Message-Id: <20170425181116.2499-1-fabf@skynet.be> X-Mailer: git-send-email 2.9.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1300 Lines: 62 This script removes NULL check on kmap() and all process involved (OOM message ...) Thanks to Jan Kara for explanations. Signed-off-by: Fabian Frederick --- scripts/coccinelle/misc/kmap.cocci | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 scripts/coccinelle/misc/kmap.cocci diff --git a/scripts/coccinelle/misc/kmap.cocci b/scripts/coccinelle/misc/kmap.cocci new file mode 100644 index 0000000..9ae4a6e --- /dev/null +++ b/scripts/coccinelle/misc/kmap.cocci @@ -0,0 +1,43 @@ +/// kmap never fails; remove NULL test case. +/// +// Copyright: (C) 2017 Fabian Frederick. GPLv2. +// Comments: - +// Options: --no-includes --include-headers + +virtual patch +virtual org +virtual report +virtual context + +@r2 depends on patch@ +expression E; +position p; +@@ + +E = kmap(...); +- if (!E) { +- ... +- } + +@r depends on context || report || org @ +expression E; +position p; +@@ + +* E = kmap(...); +* if (@p!E) { +* ... +* } + +@script:python depends on org@ +p << r.p; +@@ + +cocci.print_main("kmap() can't fail, NULL check and special process is not needed", p) + +@script:python depends on report@ +p << r.p; +@@ + +msg = "WARNING: NULL check on kmap() result is not needed." +coccilib.report.print_report(p[0], msg) -- 2.9.3