From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24987 invoked by alias); 11 May 2012 16:06:48 -0000 Received: (qmail 24960 invoked by uid 22791); 11 May 2012 16:06:44 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from eu1sys200aog111.obsmtp.com (HELO eu1sys200aog111.obsmtp.com) (207.126.144.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 May 2012 16:06:31 +0000 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob111.postini.com ([207.126.147.11]) with SMTP ID DSNKT605A5xXZKj48L39aTsfNhLmZ5/hfQJB@postini.com; Fri, 11 May 2012 16:06:30 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 52D49180; Fri, 11 May 2012 16:06:27 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas6.st.com [10.75.90.73]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CB82348AA; Fri, 11 May 2012 16:06:26 +0000 (GMT) Received: from SAFEX1MAIL1.st.com ([10.75.90.1]) by Safex1hubcas6.st.com ([10.75.90.73]) with mapi; Fri, 11 May 2012 18:06:19 +0200 From: Giuseppe MONTALTO To: Tom Tromey Cc: "gdb-patches@sourceware.org" Date: Fri, 11 May 2012 16:06:00 -0000 Subject: RE: [PATCH] new MI command for pattern filling of memory regions Message-ID: <76FE3225DF13124EA2D05B290B624C95E65FECE56F@SAFEX1MAIL1.st.com> 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> In-Reply-To: <87397624b9.fsf@fleche.redhat.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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-05/txt/msg00412.txt.bz2 Thanks, my answers are interleaved below. > -----Original Message----- > From: Tom Tromey [mailto:tromey@redhat.com] > Sent: Friday, May 11, 2012 4:14 PM > To: Giuseppe MONTALTO > Cc: gdb-patches@sourceware.org > Subject: Re: [PATCH] new MI command for pattern filling of memory > regions >=20 > The indentation is wrong here and elsewhere in the patch. > There are missing spaces as well. > See the GNU Coding Standards for details. I'll try to better format the code. >=20 > I don't think the cast here, or other casts in the patch, are > necessary. Consider them gone. >=20 > Giuseppe> + /* pattern is made of less bytes than count: > Giuseppe> + repeat pattern to fill memory. */ > Giuseppe> + data =3D xmalloc (count/len); >=20 > This allocates count/len bytes... >=20 > Giuseppe> + steps =3D count/len; > Giuseppe> + for (j =3D 0; j < steps; j++) > Giuseppe> + { > Giuseppe> + for (i =3D 0; i < len; ++i) > Giuseppe> + { > Giuseppe> + int x; > Giuseppe> + sscanf (cdata + i * 2, "%02x", &x); > Giuseppe> + data[i + j * len] =3D (gdb_byte)x; >=20 > ... but writes 'count' bytes. you're right; I was supposed to allocate 'count' bytes. Incidentally, there's a worse error there:=20 is that I'm counting the cycles basing on the result of an integer=20 division, hence not taking into account the spare bytes! I'll fix that too... Giuseppe