From: Pedro Alves <palves@redhat.com>
To: Yao Qi <yao@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] s/sprint/xsnprintf/ in remote.c
Date: Thu, 08 Mar 2012 11:05:00 -0000 [thread overview]
Message-ID: <4F58924E.7060101@redhat.com> (raw)
In-Reply-To: <1331185673-25417-1-git-send-email-yao@codesourcery.com>
On 03/08/2012 05:47 AM, Yao Qi wrote:
> @@ -8002,7 +8009,7 @@ remote_insert_hw_breakpoint (struct gdbarch *gdbarch,
> {
> CORE_ADDR addr;
> struct remote_state *rs;
> - char *p;
> + char *p, *endbuf;
>
> /* The length field should be set to the size of a breakpoint
> instruction, even though we aren't inserting one ourselves. */
> @@ -8015,6 +8022,7 @@ remote_insert_hw_breakpoint (struct gdbarch *gdbarch,
>
> rs = get_remote_state ();
> p = rs->buf;
> + endbuf = rs->buf + get_remote_packet_size ();
>
> *(p++) = 'Z';
> *(p++) = '1';
> @@ -8022,10 +8030,11 @@ remote_insert_hw_breakpoint (struct gdbarch *gdbarch,
>
> addr = remote_address_masked (bp_tgt->placed_address);
> p += hexnumstr (p, (ULONGEST) addr);
> - sprintf (p, ",%x", bp_tgt->placed_size);
> + xsnprintf (p, rs->buf + get_remote_packet_size () - p, ",%x",
> + bp_tgt->placed_size);
You seem to have endbuf handy, so `endbuf - p' would be better.
>
> if (remote_supports_cond_breakpoints ())
> - remote_add_target_side_condition (gdbarch, bp_tgt, p);
> + remote_add_target_side_condition (gdbarch, bp_tgt, p, endbuf);
>
> putpkt (rs->buf);
> getpkt (&rs->buf, &rs->buf_size, 0);
> @@ -8060,7 +8069,8 @@ remote_remove_hw_breakpoint (struct gdbarch *gdbarch,
>
> addr = remote_address_masked (bp_tgt->placed_address);
> p += hexnumstr (p, (ULONGEST) addr);
> - sprintf (p, ",%x", bp_tgt->placed_size);
> + xsnprintf (p, rs->buf + get_remote_packet_size () - p, ",%x",
> + bp_tgt->placed_size);
Would probably make sense for consistency with
remote_insert_hw_breakpoint to do `endbuf - p' here too.
Otherwise looks fine. Thanks for doing this.
--
Pedro Alves
next prev parent reply other threads:[~2012-03-08 11:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-08 5:48 Yao Qi
2012-03-08 11:05 ` Pedro Alves [this message]
2012-03-08 12:50 ` [committed] : " Yao Qi
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=4F58924E.7060101@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=yao@codesourcery.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