001-mcfv4e_checkfiles_script.patch 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From d54d785a28afb65811c5d5ad727c57233deb6f60 Mon Sep 17 00:00:00 2001
  2. From: Kurt Mahan <[email protected]>
  3. Date: Wed, 31 Oct 2007 16:36:51 -0600
  4. Subject: [PATCH] Scripts to allow running files through checkpatch.pl
  5. Scripts based on scripts/checkfiles that are in various trees.
  6. These should not be sent up because there are already patches from
  7. the original script author.
  8. LTIBName: mcfv4e-checkfiles-script
  9. Signed-off-by: Kurt Mahan <[email protected]>
  10. ---
  11. scripts/checkfiles | 35 +++++++++++++++++++++++++++++++++++
  12. scripts/checkfilesterse | 34 ++++++++++++++++++++++++++++++++++
  13. 2 files changed, 69 insertions(+), 0 deletions(-)
  14. create mode 100755 scripts/checkfiles
  15. create mode 100755 scripts/checkfilesterse
  16. --- /dev/null
  17. +++ b/scripts/checkfiles
  18. @@ -0,0 +1,35 @@
  19. +#!/bin/sh
  20. +# (c) 2007, Erez Zadok <[email protected]> (initial version)
  21. +# Licensed under the terms of the GNU GPL License version 2
  22. +#
  23. +# Check source files for compliance with coding standards, using terse
  24. +# output in the style that g/cc produces. This output can be easily parsed
  25. +# within text editors (e.g., emacs/vim) which can produce a split text
  26. +# screen showing in one screen the error message, and in another screen the
  27. +# corresponding source file, with the cursor placed on the offending line.
  28. +# See for example the documentation for Emacs's "next-error" command, often
  29. +# bound to M-x ` (ESC x back-tick).
  30. +
  31. +# Usage: checkfiles file [files...]
  32. +# if "file" is a directory, will check all *.[hc] files recursively
  33. +
  34. +# check usage
  35. +usage() {
  36. + echo "Usage: checkfiles file [files...]"
  37. + echo "(if \"file\" is a directory, check recursively for all C sources/headers)"
  38. + exit 1
  39. +}
  40. +
  41. +# if test -z "$@" ; then
  42. +# usage
  43. +# fi
  44. +if ! test -f scripts/checkpatch.pl ; then
  45. + echo "checkfiles: must run from top level source tree"
  46. + exit 1
  47. +fi
  48. +
  49. +# check coding-style compliance of each source file found
  50. +find "$@" -type f -name '*.[hc]' | \
  51. +while read f ; do
  52. + diff -u /dev/null $f | perl scripts/checkpatch.pl -
  53. +done
  54. --- /dev/null
  55. +++ b/scripts/checkfilesterse
  56. @@ -0,0 +1,34 @@
  57. +#!/bin/sh
  58. +# (c) 2007, Erez Zadok <[email protected]> (initial version)
  59. +# Licensed under the terms of the GNU GPL License version 2
  60. +#
  61. +# Check source files for compliance with coding standards, using terse
  62. +# output in the style that g/cc produces. This output can be easily parsed
  63. +# within text editors (e.g., emacs/vim) which can produce a split text
  64. +# screen showing in one screen the error message, and in another screen the
  65. +# corresponding source file, with the cursor placed on the offending line.
  66. +# See for example the documentation for Emacs's "next-error" command, often
  67. +# bound to M-x ` (ESC x back-tick).
  68. +
  69. +# Usage: checkfiles file [files...]
  70. +# if "file" is a directory, will check all *.[hc] files recursively
  71. +
  72. +# check usage
  73. +usage() {
  74. + echo "Usage: checkfiles file [files...]"
  75. + echo "(if \"file\" is a directory, check recursively for all C sources/headers)"
  76. + exit 1
  77. +}
  78. +if test -z "" ; then
  79. + usage
  80. +fi
  81. +if ! test -f scripts/checkpatch.pl ; then
  82. + echo "checkfiles: must run from top level source tree"
  83. + exit 1
  84. +fi
  85. +
  86. +# check coding-style compliance of each source file found, using terse output
  87. +find "$@" -type f -name '*.[hc]' | \
  88. +while read f ; do
  89. + diff -u /dev/null $f | perl scripts/checkpatch.pl -t -
  90. +done