Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] [gdb] Fix unbound variable in regformats/regdat.sh
Date: Fri, 28 Aug 2026 14:04:39 +0200	[thread overview]
Message-ID: <20260828120439.3857602-3-tdevries@suse.de> (raw)
In-Reply-To: <20260828120439.3857602-1-tdevries@suse.de>

While testing the previous patch, I noticed the following difference:
...
$ sh ./gdb/regformats/regdat.sh \
      gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat \
      gdbsupport/osabi.def \
      tmp.txt
$ ./gdb/regformats/regdat.sh \
      gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat \
      gdbsupport/osabi.def \
      tmp.txt
./gdb/regformats/regdat.sh: line 33: comment: unbound variable
...

The difference is due to the start of regdat.sh:
...
 #!/bin/sh -u
...
where -u is enabling the unbound variable check.

In the first variant, this setting is ignored.

Fix this by using "set -u" instead, making sure that the unbound variable
check is done for both variants.

The comment variable is not used in a meaningful way, so fix the unbound
variable error by removing it.

Tested in the same way as the preceding patch.
---
 gdb/regformats/regdat.sh | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index 01f2dabe459..f93270ba0ca 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -1,4 +1,4 @@
-#!/bin/sh -u
+#!/bin/sh
 
 # Register protocol definitions for GDB, the GNU debugger.
 # Copyright (C) 2001-2026 Free Software Foundation, Inc.
@@ -18,6 +18,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+set -u
+
 # Format of the input files
 read="type entry"
 
@@ -28,15 +30,11 @@ do_read ()
     while read -r line
     do
 	if test "${line}" = ""
-	then
-	    continue
-	elif test "${line}" = "#" -a "${comment}" = ""
 	then
 	    continue
 	elif expr "${line}" : "#" > /dev/null
 	then
-	    comment="${comment}
-${line}"
+	    continue
 	else
 
 	    # The semantics of IFS varies between different SH's.  Some
-- 
2.51.0


  parent reply	other threads:[~2026-08-28 12:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 12:04 [PATCH 0/2] [gdb] Two regformats/regdat.sh fixes Tom de Vries
2026-08-28 12:04 ` [PATCH 1/2] [gdb] Make regformats/regdat.sh shellcheck-clean Tom de Vries
2026-08-28 12:43   ` Simon Marchi
2026-08-28 14:40     ` Tom de Vries
2026-08-28 13:34   ` Andreas Schwab
2026-08-28 14:04     ` Tom de Vries
2026-08-28 12:04 ` Tom de Vries [this message]
2026-08-28 12:46   ` [PATCH 2/2] [gdb] Fix unbound variable in regformats/regdat.sh Simon Marchi
2026-08-28 14:19     ` Tom de Vries

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=20260828120439.3857602-3-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@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