]> git.ipfire.org Git - thirdparty/util-linux.git/blob - tools/checkxalloc.sh
lib/fileutils: add close_all_fds()
[thirdparty/util-linux.git] / tools / checkxalloc.sh
1 #!/bin/sh
2 #
3 # Find files which include the xalloc.h header, but which still call
4 # the unwrapped calloc and malloc.
5 #
6
7 cd "$(git rev-parse --show-toplevel)" || {
8 echo "error: failed to chdir to git root"
9 exit 1
10 }
11
12 git grep -zl '#include "xalloc.h"' |
13 xargs -0 grep -nE '\b(([cm]|re)alloc|strdup|asprintf)[[:space:]]*\([^)]'
14
15 result=$?
16
17 if [ $result -eq 123 ]; then
18 exit 0 # not found
19 elif [ $result -eq 0 ]; then
20 exit 1 # found
21 fi
22
23 exit $result