From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17594 invoked by alias); 19 Oct 2012 16:34:45 -0000 Received: (qmail 17009 invoked by uid 22791); 19 Oct 2012 16:34:43 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RCVD_IN_NIX_SPAM,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout21.012.net.il (HELO mtaout21.012.net.il) (80.179.55.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Oct 2012 16:34:34 +0000 Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0MC500L00F6N6C00@a-mtaout21.012.net.il> for gdb-patches@sourceware.org; Fri, 19 Oct 2012 18:34:32 +0200 (IST) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MC500KLIFDKW990@a-mtaout21.012.net.il>; Fri, 19 Oct 2012 18:34:32 +0200 (IST) Date: Fri, 19 Oct 2012 16:34:00 -0000 From: Eli Zaretskii 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) In-reply-to: <76FE3225DF13124EA2D05B290B624C95E66C43ADB1@SAFEX1MAIL1.st.com> To: Giuseppe MONTALTO Cc: palves@redhat.com, tromey@redhat.com, gdb-patches@sourceware.org, Hafiz_Abid@mentor.com Reply-to: Eli Zaretskii Message-id: <831ugu1kvm.fsf@gnu.org> 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> <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> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-10/txt/msg00351.txt.bz2 > From: Giuseppe MONTALTO > Cc: "palves@redhat.com" , > "tromey@redhat.com" , > "gdb-patches@sourceware.org" , > "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.