public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH] gdb: remove casts to long in dwarf2/loc.c
Date: Mon,  4 Dec 2023 15:40:19 -0500	[thread overview]
Message-ID: <20231204204021.889415-1-simon.marchi@efficios.com> (raw)

I spotted this while reviewing another patch, these casts to long are
unnecessary.  The result of subtracting two pointers is ptrdiff_t, which
can be printed with the `t` length specifier.

Change-Id: Idf8052b110a61007261be19137e4864ae6b37190
---
 gdb/dwarf2/loc.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 5b2d58ab44e4..606c97c745de 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -3329,10 +3329,9 @@ disassemble_dwarf_expression (struct ui_file *stream,
       name = get_DW_OP_name (op);
 
       if (!name)
-	error (_("Unrecognized DWARF opcode 0x%02x at %ld"),
-	       op, (long) (data - 1 - start));
-      gdb_printf (stream, "  %*ld: %s", indent + 4,
-		  (long) (data - 1 - start), name);
+	error (_("Unrecognized DWARF opcode 0x%02x at %td"), op,
+	       data - 1 - start);
+      gdb_printf (stream, "  %*td: %s", indent + 4, data - 1 - start, name);
 
       switch (op)
 	{
@@ -3515,15 +3514,13 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	case DW_OP_skip:
 	  l = extract_signed_integer (data, 2, gdbarch_byte_order (arch));
 	  data += 2;
-	  gdb_printf (stream, " to %ld",
-		      (long) (data + l - start));
+	  gdb_printf (stream, " to %td", data + l - start);
 	  break;
 
 	case DW_OP_bra:
 	  l = extract_signed_integer (data, 2, gdbarch_byte_order (arch));
 	  data += 2;
-	  gdb_printf (stream, " %ld",
-		      (long) (data + l - start));
+	  gdb_printf (stream, " %td", data + l - start);
 	  break;
 
 	case DW_OP_call2:

base-commit: 9d8fc40eb0e611162844eb7b89f1c76875153fbe
-- 
2.43.0


             reply	other threads:[~2023-12-04 20:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04 20:40 Simon Marchi [this message]
2023-12-05  8:06 ` Tom de Vries
2023-12-05 16:11   ` Simon Marchi
2023-12-05 19:21     ` Tom Tromey

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=20231204204021.889415-1-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).