From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12607 invoked by alias); 20 Feb 2014 16:37:04 -0000 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 Received: (qmail 12597 invoked by uid 89); 20 Feb 2014 16:37:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Feb 2014 16:37:01 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1KGavYD021449 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 Feb 2014 11:36:57 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1KGatoT030412; Thu, 20 Feb 2014 11:36:56 -0500 Message-ID: <53062F27.7040907@redhat.com> Date: Thu, 20 Feb 2014 16:37:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Pierre Muller , GDB Patches Subject: Re: [PATCH 5/7] go32-nat.c: Don't install a deprecated_xfer_memory method References: <1392841775-19126-1-git-send-email-palves@redhat.com> <1392841775-19126-6-git-send-email-palves@redhat.com> <00c801cf2e59$acae60f0$060b22d0$@muller@ics-cnrs.unistra.fr> In-Reply-To: <00c801cf2e59$acae60f0$060b22d0$@muller@ics-cnrs.unistra.fr> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-02/txt/msg00646.txt.bz2 (adding back gdb-patches@) On 02/20/2014 04:34 PM, Pierre Muller wrote: > I found something that looks suspicious in your patch... > But once again, it could be my lack of proper C formation... > >> +/* Const-correct version of DJGPP's write_child, which unfortunately >> + takes a non-const buffer pointer. */ >> + >> static int >> +my_write_child (unsigned child_addr, const void *buf, unsigned len) >> { >> - if (write) >> + static void *buffer = NULL; >> + static unsigned buffer_len = 0; > It seems odd to me to use > a static variable buffer_len, which keeps the size > of the last allocated buffer, when you do > a xfree before returning from this function... > >> + int res; >> + >> + if (buffer_len < len) >> { >> - if (write_child (memaddr, myaddr, len)) >> - { >> - return 0; >> - } >> - else >> - { >> - return len; >> - } >> + buffer = xrealloc (buffer, len); >> + buffer_len = len; >> } >> + >> + memcpy (buffer, buf, len); >> + res = write_child (child_addr, buffer, len); >> + xfree (buffer); > This line should be removed, or did I miss something? You're right. I'll remove it. Thanks! -- Pedro Alves