perf tests stat+shadow_stat.sh: Fix all POSIX sh warnings found using shellcheck
authorSpoorthy S <spoorts2@in.ibm.com>
Tue, 13 Jun 2023 16:41:42 +0000 (22:11 +0530)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 14 Jun 2023 02:40:34 +0000 (23:40 -0300)
Running shellcheck -S on stat+shadow_stat.sh testcase, generates
SC2046 and SC2034 warnings,

$ shellcheck -S warning tests/shell/stat+shadow_stat.sh
res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
   : Quote this to prevent word splitting

To address the POSIX shell warnings used quotes in the printf
expressions, to prevent word splitting.

Signed-off-by: Spoorthy S <spoorts2@in.ibm.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230613164145.50488-15-atrajeev@linux.vnet.ibm.com
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/shell/stat+shadow_stat.sh

index e6e35fc..0e9cba8 100755 (executable)
@@ -33,7 +33,7 @@ test_global_aggr()
                fi
 
                # use printf for rounding and a leading zero
-               res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
+               res=`printf "%.2f" "$(echo "scale=6; $num / $cyc" | bc -q)"`
                if [ "$ipc" != "$res" ]; then
                        echo "IPC is different: $res != $ipc  ($num / $cyc)"
                        exit 1
@@ -67,7 +67,7 @@ test_no_aggr()
                fi
 
                # use printf for rounding and a leading zero
-               res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
+               res=`printf "%.2f" "$(echo "scale=6; $num / $cyc" | bc -q)"`
                if [ "$ipc" != "$res" ]; then
                        echo "IPC is different for $cpu: $res != $ipc  ($num / $cyc)"
                        exit 1