coccicheck 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. SPATCH="`which ${SPATCH:=spatch}`"
  3. if [ ! -x "$SPATCH" ]; then
  4. echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/'
  5. exit 1
  6. fi
  7. if [ "$MODE" = "" ] ; then
  8. echo 'You have not explicitly specify the mode to use. Fallback to "report".'
  9. echo 'You can specify the mode with "make coccicheck MODE=<mode>"'
  10. echo 'Available modes are: report, patch, context, org'
  11. MODE="report"
  12. fi
  13. echo ''
  14. echo 'Please check for false positives in the output before submitting a patch.'
  15. echo 'When using "patch" mode, carefully review the patch before submitting it.'
  16. echo ''
  17. function coccinelle {
  18. COCCI="$1"
  19. DIR="$2"
  20. OPT=`grep "Option" $COCCI | cut -d':' -f2`
  21. FILE=`echo $COCCI | sed "s|$DIR/||"`
  22. echo "Processing `basename $COCCI` with option(s) \"$OPT\""
  23. echo 'Message example to submit a patch:'
  24. sed -e '/\/\/\//!d' -e 's|^///||' $COCCI
  25. echo ' The semantic patch that makes this change is available'
  26. echo " in $FILE."
  27. echo ''
  28. echo ' More information about semantic patching is available at'
  29. echo ' http://coccinelle.lip6.fr/'
  30. echo ''
  31. # The option '-parse_cocci' can be used to syntaxically check the SmPL files.
  32. #
  33. # $SPATCH -D $MODE -very_quiet -parse_cocci $COCCI $OPT > /dev/null
  34. $SPATCH -D $MODE -very_quiet -sp_file $COCCI $OPT -dir $DIR
  35. }
  36. if [ "$COCCI" = "" ] ; then
  37. for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do
  38. coccinelle $f $srctree;
  39. done
  40. else
  41. coccinelle $COCCI $srctree
  42. fi