mirror of
https://github.com/ericonr/util-linux.git
synced 2024-04-21 09:12:35 -05:00
Using the -w flag with grep actually fought against us here, and hid some instances where xalloc functions weren't used. Discard it in favor of an explicit word boundary as a prefix to the function name, and extend our requirements on the trailing side of the pattern. This also fixes the few new instances that were overlooked because of the regex's deficiency. [kzak@redhat.com: - fix also newfound in findmnt - remove unnecessary checks after xallocs] Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Karel Zak <kzak@redhat.com>
24 lines
457 B
Bash
Executable File
24 lines
457 B
Bash
Executable File
#!/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 -nE '\b(([cm]|re)alloc|strdup|asprintf)[[:space:]]*\([^)]'
|
|
|
|
result=$?
|
|
|
|
if [ $result -eq 123 ]; then
|
|
exit 0 # not found
|
|
elif [ $result -eq 0 ]; then
|
|
exit 1 # found
|
|
fi
|
|
|
|
exit $result
|