summaryrefslogtreecommitdiffhomepage
path: root/tools/grep_avoided_functions.sh
blob: 26681a4366ce2e1fde530b925dc947dfb4cae42a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash

# List of functions which should not be used with remarkable reasons
FUNCS=(
# On a 32-bit platform, int type is not big enough to convert into uint32 type.
# strconv.Atoi() should be replaced by strconv.ParseUint() or
# strconv.ParseInt().
'strconv\.Atoi'
)

SCRIPT_DIR=`dirname $0`
cd "${SCRIPT_DIR}/.."

RESULT=0

PKG_BASE=github.com/osrg/gobgp

for FUNC in ${FUNCS[@]}
do
    for GO_PKG in $(go list $PKG_BASE/... | grep -v '/vendor/')
    do
        grep ${FUNC} -r ${GO_PKG#$PKG_BASE/}
        if [ $? -ne 1 ]
        then
            RESULT=1
        fi
    done
done

exit $RESULT