Received: from eggs.gnu.org ([2001:4830:134:3::10]:46476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr3Pn-0002E3-Uf for qemu-devel@nongnu.org; Thu, 23 Mar 2017 10:08:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr3Pj-0004Hr-0b for qemu-devel@nongnu.org; Thu, 23 Mar 2017 10:08:35 -0400 From: Markus Armbruster References: <20170322204844.446-1-f4bug@amsat.org> <20170322204844.446-2-f4bug@amsat.org> <87y3vw1o94.fsf@dusky.pond.sub.org> <1490255007.463.11.camel@redhat.com> <1490262680.463.27.camel@redhat.com> <87tw6ktban.fsf@dusky.pond.sub.org> <1490277406.13302.1.camel@redhat.com> Date: Thu, 23 Mar 2017 15:08:24 +0100 In-Reply-To: <1490277406.13302.1.camel@redhat.com> (Gerd Hoffmann's message of "Thu, 23 Mar 2017 14:56:46 +0100") Message-ID: <878tnwm6g7.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Michael Roth , Peter Crosthwaite , qemu-trivial@nongnu.org, Alexander Graf , qemu-devel@nongnu.org, =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Philippe =?utf-8?Q?Mathieu-Daud?= =?utf-8?Q?=C3=A9?= Gerd Hoffmann writes: > On Do, 2017-03-23 at 13:41 +0100, Markus Armbruster wrote: >> Gerd Hoffmann writes: >> >> > Hi, >> > >> >> oops, there are hard-coded calls with NULL/0. I suppose to fix clang >> >> warning, it would need to check if data != null for memcpy. >> > >> > I'd check for len > 0, and in that if branch we can also assert on data >> > == NULL and thereby check that len and data are consistent. >> >> If len is non-zero but data is null, memcpy() will crash just fine by >> itself, so why bother asserting. > > To make clang happy? But maybe clang is clever enough to figure data > can't be null at that point in case we call memcpy with len != 0 > only ... If Clang needs another hint to become happy, then an assertion is a fine way to provide it.