This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] enhancement of mi_cmd_data_write_memory_bytes for filling memory regions (was [PATCH] new MI command for pattern filling of memory regions)
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Giuseppe MONTALTO <giuseppe dot montalto at st dot com>
- Cc: palves at redhat dot com, tromey at redhat dot com, gdb-patches at sourceware dot org, Hafiz_Abid at mentor dot com
- Date: Fri, 19 Oct 2012 18:34:21 +0200
- Subject: Re: [PATCH] enhancement of mi_cmd_data_write_memory_bytes for filling memory regions (was [PATCH] new MI command for pattern filling of memory regions)
- References: <76FE3225DF13124EA2D05B290B624C95E65F2D466E@SAFEX1MAIL1.st.com> <87sjf9rzr0.fsf@fleche.redhat.com> <76FE3225DF13124EA2D05B290B624C95E65FECE356@SAFEX1MAIL1.st.com> <871umsqgu8.fsf@fleche.redhat.com> <76FE3225DF13124EA2D05B290B624C95E65FECE48F@SAFEX1MAIL1.st.com> <87397624b9.fsf@fleche.redhat.com> <76FE3225DF13124EA2D05B290B624C95E662A6921F@SAFEX1MAIL1.st.com> <EB3B29AD43CA924DA27099BC851923762992F7@EU-MBX-03.mgc.mentorg.com> <76FE3225DF13124EA2D05B290B624C95E6632A4256@SAFEX1MAIL1.st.com> <878vcc1s9f.fsf@fleche.redhat.com> <76FE3225DF13124EA2D05B290B624C95E66B003EA8@SAFEX1MAIL1.st.com> <87wqzgwm4k.fsf@fleche.redhat.com> <76FE3225DF13124EA2D05B290B624C95E66B004AC6@SAFEX1MAIL1.st.com> <50802300.6040304@redhat.com> <76FE3225DF13124EA2D05B290B624C95E66B370299@SAFEX1MAIL1.st.com> <83pq4f1yda.fsf@gnu.org> <76FE3225DF13124EA2D05B290B624C95E66C43ADB1@SAFEX1MAIL1.st.com>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> From: Giuseppe MONTALTO <giuseppe.montalto@st.com>
> Cc: "palves@redhat.com" <palves@redhat.com>,
> "tromey@redhat.com" <tromey@redhat.com>,
> "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
> "Hafiz_Abid@mentor.com" <Hafiz_Abid@mentor.com>
> Date: Fri, 19 Oct 2012 16:11:50 +0200
>
> Incidentally, the attached patch contains the sscanf() version of the loop mentioned here below:
>
> for (i = 0; i < len; ++i)
> {
> int x;
> if (sscanf (cdata + i * 2, "%02x", &x) != 1)
> error (_("Invalid argument"));
> databuf[i] = (gdb_byte) x;
> }
>
> While, on the other hand, using strtoul() instead of sscanf() will lead to something
> like this, or so I guess:
>
> for (i = 0; i < len; ++i)
> databuf[i] = strtoul (cdata + i * 2, NULL, 16);
>
> The former still being my preferred one, I think it all comes down to personal taste, doesn't it?
Not necessarily. If you pass a non-NULL 2nd argument to strtoul, you
can check for errors with better accuracy.