From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agw6L-000649-6I for qemu-devel@nongnu.org; Fri, 18 Mar 2016 11:14:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agw6H-0007WJ-0u for qemu-devel@nongnu.org; Fri, 18 Mar 2016 11:14:09 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:36414) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agw6G-0007WF-QW for qemu-devel@nongnu.org; Fri, 18 Mar 2016 11:14:04 -0400 Received: by mail-wm0-x243.google.com with SMTP id l68so6891674wml.3 for ; Fri, 18 Mar 2016 08:14:04 -0700 (PDT) Sender: Paolo Bonzini References: <1458057598-11041-1-git-send-email-dhannawatpooja1@gmail.com> <20160317145025.GN14062@stefanha-x1.localdomain> <56EB34A7.9030601@redhat.com> <56EBEBAF.2090108@redhat.com> From: Paolo Bonzini Message-ID: <56EC1B3A.8020004@redhat.com> Date: Fri, 18 Mar 2016 16:14:02 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pooja Dhannawat , Jaya Tiwari Cc: Stefan Hajnoczi , qemu-devel@nongnu.org On 18/03/2016 14:49, Pooja Dhannawat wrote: > > > If it is greater than the accepted level, the on-stack > buffer is not > used and you allocate one that has the right size on the heap. > > Yes Okay. Thank you for the comments. > I had one more question. > size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); > The one above returns bytes read into buf1 (if large then bytes > equivalent to len(buf1) is read) ? > If true, size is the correct measure of buf1? Hence, I should > compare the allowed stack size to "size" variable? > > So isnt here size should be compared to "size" varibale paolo? > > So instead of comparing with NET_BUFSIZE, should I compare with "size" > variable? Can you help me with this? I was a bit confused myself; this function actually is a bit different from the others because it does not really need a large buffer. The function already takes care of moving data in pieces from buf1 to s->buf. If you make the buffer smaller, the only change is that one call to net_socket_send will process fewer bytes. So you can just send a trivial patch that changes the size of the array to something like 2048. Thanks, and sorry for putting you on a false track! Paolo