From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751250AbdH2FTE (ORCPT ); Tue, 29 Aug 2017 01:19:04 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:48276 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750758AbdH2FSA (ORCPT ); Tue, 29 Aug 2017 01:18:00 -0400 X-IronPort-AV: E=Sophos;i="5.41,443,1498514400"; d="scan'208";a="288659019" Date: Tue, 29 Aug 2017 07:17:58 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Joe Perches cc: cocci , LKML Subject: Re: [Cocci] cocci: remove unnecessary casts of void * while avoiding casts with __user or __force ? In-Reply-To: <1503938959.2040.6.camel@perches.com> Message-ID: References: <1503938959.2040.6.camel@perches.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 Aug 2017, Joe Perches wrote: > A simple cocci script that removes unnecessary casts of > a void * will also remove casts with __force or __user Unfortunately, attributes are currently not supported inside casts. This can be done in a hackish way (possible false negatives) as follows: --- @initialize:ocaml@ @@ let close (p1,p2) = let r = (List.hd p1).line_end in let l = (List.hd p2).line in let rc = (List.hd p1).col_end in let lc = (List.hd p2).col in r = l && lc = rc+1 @r@ position p1,p2; expression f,e; type T; @@ f(..., // generalize this rule as needed (T@p1 *@p2) e,...) @@ position r.p2 : script:ocaml(r.p1) { close(p1,p2) }; position r.p1; expression e; type T; @@ - (T@p1 *@p2) e --- Basically, it assumes that if the type and the * are more than one space apart then there is something important there, and the cast is not removed. julia