public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: remove casts to long in dwarf2/loc.c
@ 2023-12-04 20:40 Simon Marchi
  2023-12-05  8:06 ` Tom de Vries
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2023-12-04 20:40 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-05 19:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-04 20:40 [PATCH] gdb: remove casts to long in dwarf2/loc.c Simon Marchi
2023-12-05  8:06 ` Tom de Vries
2023-12-05 16:11   ` Simon Marchi
2023-12-05 19:21     ` Tom Tromey

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).