From 8420d732b682a16fa34fb50725ce4c717287ecfd Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Fri, 12 Jan 2018 14:51:03 +0900 Subject: travis: Script to checkout use of avoided functions For the 32-bit platform compatibility, strconv.Atoi() should be replaced by strconv.ParseUint() or strconv.ParseInt(). This scripts prevents the use of these functions which should not be used with some reasons. Signed-off-by: IWASE Yusuke --- tools/grep_avoided_functions.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 tools/grep_avoided_functions.sh (limited to 'tools') diff --git a/tools/grep_avoided_functions.sh b/tools/grep_avoided_functions.sh new file mode 100755 index 00000000..d5b6494b --- /dev/null +++ b/tools/grep_avoided_functions.sh @@ -0,0 +1,27 @@ +#!/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` + +RESULT=0 + +for FUNC in ${FUNCS[@]} +do + for GO_PKG in $(go list github.com/osrg/gobgp/... | grep -v '/vendor/') + do + grep ${FUNC} -r ${GOPATH}/src/${GO_PKG} + if [ $? -ne 1 ] + then + RESULT=1 + fi + done +done + +exit $RESULT \ No newline at end of file -- cgit v1.2.3