changeset 12287:0c467c7c0132

maint.mk: Prohibit inclusion of "xalloc.h" without use. * top/maint.mk (sc_prohibit_close_stream_without_use): New rule.
author Jim Meyering <meyering@redhat.com>
date Sat, 14 Nov 2009 09:53:26 +0100
parents 0ef15d536366
children cbae19b6a9f8
files ChangeLog top/maint.mk
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Nov 14 08:24:25 2009 +0100
+++ b/ChangeLog	Sat Nov 14 09:53:26 2009 +0100
@@ -1,3 +1,8 @@
+2009-11-14  Jim Meyering  <meyering@redhat.com>
+
+	maint.mk: Prohibit inclusion of "xalloc.h" without use.
+	* top/maint.mk (sc_prohibit_close_stream_without_use): New rule.
+
 2009-11-14  John W. Eaton  <jwe@gnu.org>
 
 	strftime.h: wrap funtion declaration in extern "C" block
--- a/top/maint.mk	Sat Nov 14 08:24:25 2009 +0100
+++ b/top/maint.mk	Sat Nov 14 09:53:26 2009 +0100
@@ -289,6 +289,23 @@
 	re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
 	  $(_header_without_use)
 
+# Don't include xalloc.h unless you use one of its functions.
+# Consider these symbols:
+# perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
+# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) \(/ and print $1' lib/xalloc.h
+# Divide into two sets on case, and filter each through this:
+# | sort | perl -MRegexp::Assemble -le \
+#  'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
+# Note this was produced by the above:
+# _xa1 = x(alloc_(oversized|die)|([cz]|2?re)alloc|m(alloc|emdup)|strdup)
+# But we can do better:
+_xa1 = x(alloc_(oversized|die)|([cmz]|2?re)alloc|(mem|str)dup)
+_xa2 = X([CZ]|N?M)ALLOC
+sc_prohibit_xalloc_without_use:
+	@h='"xalloc.h"' \
+	re='\<($(_xa1)|$(_xa2)) *\('\
+	  $(_header_without_use)
+
 sc_prohibit_safe_read_without_use:
 	@h='"safe-read.h"' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
 	  $(_header_without_use)