mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-10-05 00:08:22 +00:00
There are some functions we decided to avoid using, so add a test to make sure we won't add them by accident. Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
26 lines
828 B
Bash
Executable File
26 lines
828 B
Bash
Executable File
#!/usr/bin/env bats
|
|
|
|
# Author: Otavio Pontes
|
|
# Email: otavio.pontes@intel.com
|
|
@test "ANL004: Functions to avoid" {
|
|
|
|
# There are some C functions that are tricky to use and it's prefered to
|
|
# avoid using them in swupd. If any function in this list is really needed
|
|
# we need to review the usage and add an exception here.
|
|
local functions="strcpy wcscpy strcat wcscat sprintf vsprintf strtok ato strlen wcslen alloca vscanf vsscanf vfscanf scanf sscanf fscanf strncat strsep toa memmove asctime getwd strlen gets"
|
|
|
|
local error=0
|
|
for func in $functions; do
|
|
run grep "\<$func(" src --include "*.c" --include "*.h" -R
|
|
# shellcheck disable=SC2154
|
|
# SC2154: var is referenced but not assigned
|
|
if [ "$status" -eq "0" ]; then
|
|
echo "Found $func on files:"
|
|
echo "$output"
|
|
error=1
|
|
fi
|
|
done
|
|
|
|
[ "$error" -eq "0" ]
|
|
}
|