bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

more syntax checks


From: Simon Josefsson
Subject: more syntax checks
Date: Fri, 03 Mar 2006 15:09:23 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Installed.

There should be some mechanism to exclude certain files on a per-rule
basis.  I'm not yet sure how to do this.  Ideas appreciated.

It should also be possible to add local syntax checks rules in
maint-cfg.mk, and have them used automatically.

It should also be possible to disable certain syntax checks rules that
doesn't work well for a specific project.

2006-03-03  Simon Josefsson  <address@hidden>

        * build-aux/maint.mk: Add several syntax checks from CoreUtils.

--- maint.mk    03 Mar 2006 14:29:53 +0100      1.3
+++ maint.mk    03 Mar 2006 15:06:46 +0100      
@@ -45,6 +45,62 @@
          { echo '$(ME): don'\''t cast free argument' 1>&2;             \
            exit 1; } || :
 
+sc_cast_of_x_alloc_return_value:
+       @grep -nE '\*\) *x(m|c|re)alloc\>' $(C_SOURCES) &&              \
+         { echo '$(ME): don'\''t cast x*alloc return value' 1>&2;      \
+           exit 1; } || :
+
+sc_cast_of_alloca_return_value:
+       @grep -nE '\*\) *alloca\>' $(C_SOURCES) &&                      \
+         { echo '$(ME): don'\''t cast alloca return value' 1>&2;       \
+           exit 1; } || :
+
+sc_space_tab:
+       @grep -n '[ ]   ' $(C_SOURCES) &&                               \
+         { echo '$(ME): found SPACE-TAB sequence; remove the SPACE'    \
+               1>&2; exit 1; } || :
+
+# Don't use the old ato* functions in `real' code.
+# They provide no error checking mechanism.
+# Instead, use strto* functions.
+sc_prohibit_atoi_atof:
+       @grep -nE '\<ato([filq]|ll)\>' $(C_SOURCES) &&                  \
+         { echo '$(ME): do not use ato''f, ato''i, ato''l, ato''ll, or ato''q' 
\
+               1>&2; exit 1; } || :
+
+# Using EXIT_SUCCESS as the first argument to error is misleading,
+# since when that parameter is 0, error does not exit.  Use `0' instead.
+sc_error_exit_success:
+       @grep -nF 'error (EXIT_SUCCESS,' $(C_SOURCES) &&                \
+         { echo '$(ME): found error (EXIT_SUCCESS' 1>&2;               \
+           exit 1; } || :
+
+# Stylistic, use #ifdef instead of #if
+sc_no_if_have_config_h:
+       @grep -n '^# *if HAVE_CONFIG_H' $(C_SOURCES) &&                 \
+         { echo '$(ME): found use of #if HAVE_CONFIG_H; use #ifdef'    \
+               1>&2; exit 1; } || :
+
+# Prohibit the inclusion of assert.h without an actual use of assert.
+sc_prohibit_assert_without_use:
+       @files=$$(grep -l '# *include [<"]assert\.h[>"]' $(C_SOURCES)   \
+                       | grep '\.[cy]$$') &&                           \
+       grep -L '\<assert (' $$files                                    \
+           | grep . &&                                                 \
+         { echo "$(ME): the above files include <assert.h> but don't use it" \
+               1>&2; exit 1; } || :
+
+sc_obsolete_symbols:
+       @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' $(C_SOURCES) &&     \
+         { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY'       \
+               1>&2; exit 1; } || :
+
+# Each nonempty line must start with a year number, or a TAB.
+sc_changelog:
+       @grep -n '^[^12 ]' $$(find . -name ChangeLog) &&        \
+         { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2;  \
+           exit 1; } || :
+
 # Collect the names of rules starting with `sc_'.
 syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
 .PHONY: $(syntax-check-rules)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]