idmap2: assign uninitialized variables initial values
In C++, local primitives are not automatically initialized:
void foo() {
int i; // primitive: value is indeterminate
std::string s; // class: calls default ctor
...
}
Create.cpp and Dump.cpp include this type of uninitialized variable; fix
this by explicitly assigning an initial value.
Also add a new script to help catch these types of errors in the future:
valgrind.sh, which will run a few idmap2 commands and the idmap2_tests
through Valgrind.
Also update static-checks.sh to rely on a command's return value instead
of the presence of any output.
Test: frameworks/base/cmds/idmap2/valgrind.sh
Change-Id: Ic9dbd3e9a768beb39ac677ff294b0fca5ee8f9d2
diff --git a/cmds/idmap2/static-checks.sh b/cmds/idmap2/static-checks.sh
index 41d3c69..a372abd 100755
--- a/cmds/idmap2/static-checks.sh
+++ b/cmds/idmap2/static-checks.sh
@@ -27,10 +27,11 @@
local red="\e[31m"
local green="\e[32m"
local reset="\e[0m"
+ local output
_log "${green}[ RUN ]${reset} ${label}"
- local output="$(eval "$cmd")"
- if [[ -z "${output}" ]]; then
+ output="$(eval "$cmd" 2>&1)"
+ if [[ $? -eq 0 ]]; then
_log "${green}[ OK ]${reset} ${label}"
return 0
else