diff mbox

[1/7] coccinelle: add a script to remove useless casts

Message ID 1466007277-17525-2-git-send-email-lvivier@redhat.com
State New
Headers show

Commit Message

Laurent Vivier June 15, 2016, 4:14 p.m. UTC
Script from LKML.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 scripts/coccinelle/typecast.cocci | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 scripts/coccinelle/typecast.cocci

Comments

Eric Blake June 24, 2016, 5:21 p.m. UTC | #1
On 06/15/2016 10:14 AM, Laurent Vivier wrote:
> Script from LKML.

Link to a particular message?

> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  scripts/coccinelle/typecast.cocci | 7 +++++++
>  1 file changed, 7 insertions(+)
>  create mode 100644 scripts/coccinelle/typecast.cocci
> 
> diff --git a/scripts/coccinelle/typecast.cocci b/scripts/coccinelle/typecast.cocci
> new file mode 100644
> index 0000000..be2183e
> --- /dev/null
> +++ b/scripts/coccinelle/typecast.cocci
> @@ -0,0 +1,7 @@
> +// Remove useless casts
> +@@
> +type T;
> +T v;
> +@@
> +-	(T *)&v
> ++	&v

Since we're using C for the most part, do we also want to remove useless
casts in and out of void*?

But even if we do that, it could be separate.  This patch looks good on
its own:

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox

Patch

diff --git a/scripts/coccinelle/typecast.cocci b/scripts/coccinelle/typecast.cocci
new file mode 100644
index 0000000..be2183e
--- /dev/null
+++ b/scripts/coccinelle/typecast.cocci
@@ -0,0 +1,7 @@ 
+// Remove useless casts
+@@
+type T;
+T v;
+@@
+-	(T *)&v
++	&v