From: Tom de Vries <tdevries@suse.de>
To: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: remove casts to long in dwarf2/loc.c
Date: Tue, 5 Dec 2023 09:06:52 +0100 [thread overview]
Message-ID: <0505f572-df32-40a6-a9c9-90896f5c52f9@suse.de> (raw)
In-Reply-To: <20231204204021.889415-1-simon.marchi@efficios.com>
On 12/4/23 21:40, Simon Marchi wrote:
> 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.
>
I'm not sure if it's relevant, but gdb_printf uses
format_pieces::format_pieces, which supports a number of length
specififers, but not 't'.
Thanks,
- Tom
> 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
next prev parent reply other threads:[~2023-12-05 8:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 20:40 Simon Marchi
2023-12-05 8:06 ` Tom de Vries [this message]
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=0505f572-df32-40a6-a9c9-90896f5c52f9@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
/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).