Skip to content

Commit

Permalink
Coccinelle: Cleanup the setting of the FLAGS and OPTIONS variables
Browse files Browse the repository at this point in the history
The FLAGS variable is factorized independently of the ONLINE mode.
The OPTIONS variable is now based on LINUXINCLUDE and explicit
includes are thus removed.

The format of the -I option differs between gcc and spatch.
The COCCIINCLUDE is used to adapt the format. This rewritting
needs bash.

Signed-off-by: Nicolas Palix <nicolas.palix@imag.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>
  • Loading branch information
Nicolas Palix authored and Michal Marek committed Apr 8, 2013
1 parent 35d88a3 commit 9e39555
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions scripts/coccicheck
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

SPATCH="`which ${SPATCH:=spatch}`"

Expand All @@ -11,24 +11,25 @@ else
VERBOSE=0
fi

FLAGS="-very_quiet"

# spatch only allows include directories with the syntax "-I include"
# while gcc also allows "-Iinclude" and "-include include"
COCCIINCLUDE=${LINUXINCLUDE//-I/-I }
COCCIINCLUDE=${COCCIINCLUDE//-include/-I}

if [ "$C" = "1" -o "$C" = "2" ]; then
ONLINE=1

# This requires Coccinelle >= 0.2.3
# FLAGS="-ignore_unknown_options -very_quiet"
# OPTIONS=$*

# Workaround for Coccinelle < 0.2.3
FLAGS="-I $srctree/include -very_quiet"
shift $(( $# - 1 ))
OPTIONS=$1
# Take only the last argument, which is the C file to test
shift $(( $# - 1 ))
OPTIONS="$COCCIINCLUDE $1"
else
ONLINE=0
FLAGS="-very_quiet"
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="-dir $srctree"
OPTIONS="-dir $srctree $COCCIINCLUDE"
else
OPTIONS="-dir $KBUILD_EXTMOD -patch $srctree -I $srctree/include -I $KBUILD_EXTMOD/include"
OPTIONS="-dir $KBUILD_EXTMOD -patch $srctree $COCCIINCLUDE"
fi
fi

Expand Down

0 comments on commit 9e39555

Please sign in to comment.