gdb: fix shellcheck warnings SC2154 (referenced but not assigned) in gdbarch.sh
Fix all instances of this kind of warning: In gdbarch.sh line 96: m ) staticdefault="${predefault}" ;; ^-----------^ SC2154: predefault is referenced but not assigned. These warnings appear because we are doing something a bit funky when reading the gdbarch fields. These variables are not assigned explicitly, but using some `eval` commands. I don't think there is so much we can fix about those warnings. To silence them, I've changed `${foo}` to `${foo:-}`. This tells the shell to substitute with an empty string if `foo` is not defined. This retains the current behavior, but the warnings go away. gdb/ChangeLog: * gdbarch.sh: Use ${foo:-} where shellcheck would report a "referenced but not assigned" warning.
This commit is contained in:
parent
9fdb2916fe
commit
1207375d76
@ -1,3 +1,8 @@
|
|||||||
|
2020-04-29 Simon Marchi <simon.marchi@efficios.com>
|
||||||
|
|
||||||
|
* gdbarch.sh: Use ${foo:-} where shellcheck would report a
|
||||||
|
"referenced but not assigned" warning.
|
||||||
|
|
||||||
2020-04-29 Simon Marchi <simon.marchi@efficios.com>
|
2020-04-29 Simon Marchi <simon.marchi@efficios.com>
|
||||||
|
|
||||||
* gdbarch.sh: Remove code that sets fallbackdefault.
|
* gdbarch.sh: Remove code that sets fallbackdefault.
|
||||||
|
@ -75,7 +75,7 @@ ${line}
|
|||||||
EOF
|
EOF
|
||||||
IFS="${OFS}"
|
IFS="${OFS}"
|
||||||
|
|
||||||
if test -n "${garbage_at_eol}"
|
if test -n "${garbage_at_eol:-}"
|
||||||
then
|
then
|
||||||
echo "Garbage at end-of-line in ${line}" 1>&2
|
echo "Garbage at end-of-line in ${line}" 1>&2
|
||||||
kill $$
|
kill $$
|
||||||
@ -93,19 +93,19 @@ EOF
|
|||||||
done
|
done
|
||||||
|
|
||||||
case "${class}" in
|
case "${class}" in
|
||||||
m ) staticdefault="${predefault}" ;;
|
m ) staticdefault="${predefault:-}" ;;
|
||||||
M ) staticdefault="0" ;;
|
M ) staticdefault="0" ;;
|
||||||
* ) test "${staticdefault}" || staticdefault=0 ;;
|
* ) test "${staticdefault}" || staticdefault=0 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "${class}" in
|
case "${class}" in
|
||||||
F | V | M )
|
F | V | M )
|
||||||
case "${invalid_p}" in
|
case "${invalid_p:-}" in
|
||||||
"" )
|
"" )
|
||||||
if test -n "${predefault}"
|
if test -n "${predefault}"
|
||||||
then
|
then
|
||||||
#invalid_p="gdbarch->${function} == ${predefault}"
|
#invalid_p="gdbarch->${function} == ${predefault}"
|
||||||
predicate="gdbarch->${function} != ${predefault}"
|
predicate="gdbarch->${function:-} != ${predefault}"
|
||||||
elif class_is_variable_p
|
elif class_is_variable_p
|
||||||
then
|
then
|
||||||
predicate="gdbarch->${function} != 0"
|
predicate="gdbarch->${function} != 0"
|
||||||
@ -139,7 +139,7 @@ EOF
|
|||||||
|
|
||||||
fallback_default_p ()
|
fallback_default_p ()
|
||||||
{
|
{
|
||||||
{ [ -n "${postdefault}" ] && [ "x${invalid_p}" != "x0" ]; } \
|
{ [ -n "${postdefault:-}" ] && [ "x${invalid_p}" != "x0" ]; } \
|
||||||
|| { [ -n "${predefault}" ] && [ "x${invalid_p}" = "x0" ]; }
|
|| { [ -n "${predefault}" ] && [ "x${invalid_p}" = "x0" ]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1206,7 +1206,7 @@ exec > new-gdbarch.log
|
|||||||
function_list | while do_read
|
function_list | while do_read
|
||||||
do
|
do
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
${class} ${returntype} ${function} ($formal)
|
${class} ${returntype:-} ${function} (${formal:-})
|
||||||
EOF
|
EOF
|
||||||
for r in ${read}
|
for r in ${read}
|
||||||
do
|
do
|
||||||
@ -2119,7 +2119,7 @@ do
|
|||||||
fi
|
fi
|
||||||
printf " if (gdbarch_debug >= 2)\n"
|
printf " if (gdbarch_debug >= 2)\n"
|
||||||
printf " fprintf_unfiltered (gdb_stdlog, \"gdbarch_%s called\\\\n\");\n" "$function"
|
printf " fprintf_unfiltered (gdb_stdlog, \"gdbarch_%s called\\\\n\");\n" "$function"
|
||||||
if [ "x${actual}" = "x-" ] || [ "x${actual}" = "x" ]
|
if [ "x${actual:-}" = "x-" ] || [ "x${actual:-}" = "x" ]
|
||||||
then
|
then
|
||||||
if class_is_multiarch_p
|
if class_is_multiarch_p
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user