Skip to content

Commit

Permalink
Merge pull request #5911 from janekmi/call_stacks-for-loop-issue
Browse files Browse the repository at this point in the history
common: work around cflow's for-loop issue
  • Loading branch information
janekmi authored Nov 10, 2023
2 parents eb16412 + 17bf986 commit 3d0f0ee
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions utils/call_stacks_analysis/make_cflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# the cflow tool.
#

UNSAFE=$1 # '-f' to omit security checks

WD=$(realpath $(dirname "$0"))
SRC=$(realpath $WD/../../src)

Expand All @@ -27,6 +29,27 @@ SOURCES=`find $SRC -name *.[ch] | grep -v -e '_other.c' -e '_none.c' \
-e '/ppc64/' -e '/riscv64/' -e '/loongarch64/' \
-e '/libpmempool/'`

ABORT=yes
UNCOMMITED=$(git status -s)

if [ "z$UNSAFE" == "z-f" ]; then
ABORT=no
elif [ -z "$UNCOMMITED" ]; then
ABORT=no
fi

if [ $ABORT == "yes" ]; then
echo "The repository has uncommitted changes. Can't continue without overwriting them."
echo "Call '$0 -f' to continue regardless."
exit 1
fi

# Note: cflow cannot process correctly a for-loop if the initialization step of
# the loop declares a variable. It doesn't care if a variable is not defined.
# So, removing the initialization step from all the for-loops works around
# the problem.
sed -i 's/for ([^;]\+;/for (;/' $SOURCES

# Note: --symbol list has been defined based on cflow manual
# https://www.gnu.org/software/cflow/manual/cflow.html
# Section: 6.3 GCC Initialization
Expand Down Expand Up @@ -74,3 +97,5 @@ cflow -o $WD/cflow.txt \
$STARTS $SOURCES 2> $WD/cflow.err

echo "Done."

echo "Note: $0 probably modified the source code."

0 comments on commit 3d0f0ee

Please sign in to comment.