From 85791b987cabd05fd07a9982be9e8f097eec9dbd Mon Sep 17 00:00:00 2001 From: David Schleef Date: Thu, 17 Jul 2003 04:30:09 +0000 Subject: [PATCH] Check for abuse of config.h Original commit message from CVS: Check for abuse of config.h --- tests/old/testsuite/gst-lint | 50 ++++++++++++++++++++++++++++-------- testsuite/gst-lint | 50 ++++++++++++++++++++++++++++-------- 2 files changed, 78 insertions(+), 22 deletions(-) diff --git a/tests/old/testsuite/gst-lint b/tests/old/testsuite/gst-lint index 4ec46e1dc7..e0c9d9cd5c 100755 --- a/tests/old/testsuite/gst-lint +++ b/tests/old/testsuite/gst-lint @@ -11,10 +11,9 @@ # Future ideas: # - spell check comments # - check each function for at least one assertion (?) -# - run indent and compare the results # - check parameters that init/set/get have consistent types -# - check for config.h in exported headers # - check for gst_caps_set() without check for writeability +# - check .so files for stray symbols # # @@ -33,6 +32,7 @@ sub check_glibisms(); sub check_indentation(); sub check_gst_props_set(); sub check_deprecated(); +sub check_config_h(); open FIND, "find . -name \"*.[ch]\" -print|"; @@ -55,6 +55,7 @@ foreach $filename () { #check_indentation(); check_gst_props_set(); check_deprecated(); + check_config_h(); } # @@ -114,15 +115,6 @@ sub check_bad_includes() print "E: bad header: malloc.h\n" } - # - # config.h should be wrapped - # - if (grep { /^#include\s+["<]config.h[">]/; } @lines) { - if(!grep { /^#ifdef HAVE_CONFIG_H/; } @lines) { - print "E: #include not surrounded by #ifdef HAVE_CONFIG_H\n" - } - } - # # Prefer "G_BEGIN_DECLS" to 'extern "C" {' # @@ -240,5 +232,41 @@ sub check_deprecated() if (grep { /GST_INFO\s*\(\s+\d/; } @lines) { print "E: old-style GST_DEBUG()\n"; } + if (grep { /GstEventFlags/; } @lines) { + print "W: who uses GstEventFlags\n"; + } + +} + +# +# Every .c file should include config.h before any other headers +# No .h file should include config.h +# +sub check_config_h() +{ + if($filename =~ /\.c$/){ + # + # config.h should be wrapped + # + my @includes = grep { /^#include/; } @lines; + + if (!grep { /^#include\s+["<]config.h[">]/; } @includes) { + print "E: #include missing\n"; + }else{ + if (!($includes[0] =~ /^#include\s+["<]config.h[">]/)){ + print "E: #include is not first include\n"; + } + if(!grep { /^#ifdef HAVE_CONFIG_H/; } @lines) { + print "E: #include not surrounded by #ifdef HAVE_CONFIG_H\n"; + } + } + } + + if($filename =~ /\.h$/){ + if (grep { /^#include\s+["<]config.h[">]/; } @lines) { + print "E: headers should not #include \n"; + } + } + } diff --git a/testsuite/gst-lint b/testsuite/gst-lint index 4ec46e1dc7..e0c9d9cd5c 100755 --- a/testsuite/gst-lint +++ b/testsuite/gst-lint @@ -11,10 +11,9 @@ # Future ideas: # - spell check comments # - check each function for at least one assertion (?) -# - run indent and compare the results # - check parameters that init/set/get have consistent types -# - check for config.h in exported headers # - check for gst_caps_set() without check for writeability +# - check .so files for stray symbols # # @@ -33,6 +32,7 @@ sub check_glibisms(); sub check_indentation(); sub check_gst_props_set(); sub check_deprecated(); +sub check_config_h(); open FIND, "find . -name \"*.[ch]\" -print|"; @@ -55,6 +55,7 @@ foreach $filename () { #check_indentation(); check_gst_props_set(); check_deprecated(); + check_config_h(); } # @@ -114,15 +115,6 @@ sub check_bad_includes() print "E: bad header: malloc.h\n" } - # - # config.h should be wrapped - # - if (grep { /^#include\s+["<]config.h[">]/; } @lines) { - if(!grep { /^#ifdef HAVE_CONFIG_H/; } @lines) { - print "E: #include not surrounded by #ifdef HAVE_CONFIG_H\n" - } - } - # # Prefer "G_BEGIN_DECLS" to 'extern "C" {' # @@ -240,5 +232,41 @@ sub check_deprecated() if (grep { /GST_INFO\s*\(\s+\d/; } @lines) { print "E: old-style GST_DEBUG()\n"; } + if (grep { /GstEventFlags/; } @lines) { + print "W: who uses GstEventFlags\n"; + } + +} + +# +# Every .c file should include config.h before any other headers +# No .h file should include config.h +# +sub check_config_h() +{ + if($filename =~ /\.c$/){ + # + # config.h should be wrapped + # + my @includes = grep { /^#include/; } @lines; + + if (!grep { /^#include\s+["<]config.h[">]/; } @includes) { + print "E: #include missing\n"; + }else{ + if (!($includes[0] =~ /^#include\s+["<]config.h[">]/)){ + print "E: #include is not first include\n"; + } + if(!grep { /^#ifdef HAVE_CONFIG_H/; } @lines) { + print "E: #include not surrounded by #ifdef HAVE_CONFIG_H\n"; + } + } + } + + if($filename =~ /\.h$/){ + if (grep { /^#include\s+["<]config.h[">]/; } @lines) { + print "E: headers should not #include \n"; + } + } + }