]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tools: add new code checking script
authorDave Reisner <d@falconindy.com>
Tue, 20 Dec 2011 13:36:04 +0000 (08:36 -0500)
committerKarel Zak <kzak@redhat.com>
Wed, 4 Jan 2012 12:53:08 +0000 (13:53 +0100)
Finds usage of strdup, malloc, calloc, and realloc when xalloc.h is
included.

http://marc.info/?l=util-linux-ng&m=132438338929925&w=2

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
tools/checkxalloc.sh [new file with mode: 0755]

diff --git a/tools/checkxalloc.sh b/tools/checkxalloc.sh
new file mode 100755 (executable)
index 0000000..89940fe
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# Find files which include the xalloc.h header, but which still call
+# the unwrapped calloc and malloc.
+#
+
+cd "$(git rev-parse --show-toplevel)" || {
+  echo "error: failed to chdir to git root"
+  exit 1
+}
+
+git grep -zl '#include "xalloc.h"' |
+  xargs -0 grep -nwE '[^x](([cm]|re)alloc|strdup)\('