public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] gdb: fix shellcheck warnings SC2154 (referenced but not assigned) in gdbarch.sh
Date: Sat, 16 May 2020 17:38:48 -0400	[thread overview]
Message-ID: <1207375d768ae2b901c3bea6543b610c461160dd@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 1207375d768ae2b901c3bea6543b610c461160dd ***

commit 1207375d768ae2b901c3bea6543b610c461160dd
Author:     Simon Marchi <simon.marchi@efficios.com>
AuthorDate: Wed Apr 29 20:35:35 2020 -0400
Commit:     Simon Marchi <simon.marchi@efficios.com>
CommitDate: Wed Apr 29 20:35:35 2020 -0400

    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.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dee9a6edd3..eb6841640b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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>
 
 	* gdbarch.sh: Remove code that sets fallbackdefault.
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 4e4cc827b8..24f8cdfe90 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -75,7 +75,7 @@ ${line}
 EOF
 	    IFS="${OFS}"
 
-	    if test -n "${garbage_at_eol}"
+	    if test -n "${garbage_at_eol:-}"
 	    then
 		echo "Garbage at end-of-line in ${line}" 1>&2
 		kill $$
@@ -93,19 +93,19 @@ EOF
 	    done
 
 	    case "${class}" in
-		m ) staticdefault="${predefault}" ;;
+		m ) staticdefault="${predefault:-}" ;;
 		M ) staticdefault="0" ;;
 		* ) test "${staticdefault}" || staticdefault=0 ;;
 	    esac
 
 	    case "${class}" in
 	    F | V | M )
-		case "${invalid_p}" in
+		case "${invalid_p:-}" in
 		"" )
 		    if test -n "${predefault}"
 		    then
 			#invalid_p="gdbarch->${function} == ${predefault}"
-			predicate="gdbarch->${function} != ${predefault}"
+			predicate="gdbarch->${function:-} != ${predefault}"
 		    elif class_is_variable_p
 		    then
 			predicate="gdbarch->${function} != 0"
@@ -139,7 +139,7 @@ EOF
 
 fallback_default_p ()
 {
-    { [ -n "${postdefault}" ] && [ "x${invalid_p}" != "x0" ]; } \
+    { [ -n "${postdefault:-}" ] && [ "x${invalid_p}" != "x0" ]; } \
 	|| { [ -n "${predefault}" ] && [ "x${invalid_p}" = "x0" ]; }
 }
 
@@ -1206,7 +1206,7 @@ exec > new-gdbarch.log
 function_list | while do_read
 do
     cat <<EOF
-${class} ${returntype} ${function} ($formal)
+${class} ${returntype:-} ${function} (${formal:-})
 EOF
     for r in ${read}
     do
@@ -2119,7 +2119,7 @@ do
 	fi
 	printf "  if (gdbarch_debug >= 2)\n"
 	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
 	    if class_is_multiarch_p
 	    then


             reply	other threads:[~2020-05-16 21:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-16 21:38 gdb-buildbot [this message]
2020-05-16 21:38 ` Failures on Fedora-i686, branch master gdb-buildbot
2020-05-16 21:46 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2020-05-16 22:12 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2020-05-16 22:20 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-05-16 22:57 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-05-16 23:04 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-05-17  1:00 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1207375d768ae2b901c3bea6543b610c461160dd@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).