From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVNhs-00046w-77 for qemu-devel@nongnu.org; Thu, 04 Aug 2016 14:49:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVNho-0001Xp-0h for qemu-devel@nongnu.org; Thu, 04 Aug 2016 14:49:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVNhn-0001XZ-RE for qemu-devel@nongnu.org; Thu, 04 Aug 2016 14:49:19 -0400 References: From: John Snow Message-ID: <1ab0c4f6-b927-55fc-7e7e-84c135edd143@redhat.com> Date: Thu, 4 Aug 2016 14:49:18 -0400 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] qtest protocol: should memset/read/write etc of a size of 0 bytes be permitted? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , QEMU Developers On 08/04/2016 02:46 PM, Peter Maydell wrote: > I've upgraded to a more recent version of clang, which now produces > undefined-behaviour warnings for passing NULL pointers to some library > functions. One of the things it has shown up is that some of the > qtest tests ask for "memset" with size zero. In our current implementation > this results in qtest.c calling g_malloc(0), which returns NULL, and > then calling memset(NULL, chr, 0), which is UB. > > So should we: > (1) declare the qtest protocol commands 'memset', 'read', 'write' > etc which operate on a lump of guest memory of specified size to > support size == 0 as meaning "do nothing" This would be easy to do. > (2) declare that size == 0 is not valid and make it return a failure > code back down the qtest pipe (and fix the offending tests) > This is probably the nicer thing to do -- if memset of length 0 is undefined, probably qmemset and friends should also be undefined by extension. I reserve the right to change my mind depending on how gnarly it is to untangle. I assume you're hoping for 2.7. > ? > > The offending tests are i386/ahci/flush/simple and i386/ahci/max > (because ahci_io() calls qmemset() with a zero size.) > > thanks > -- PMM > --js