qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers
Date: Fri, 7 Apr 2017 18:33:45 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

Hi Markus, Gerd.

On 03/23/2017 11:08 AM, Markus Armbruster wrote:
Gerd Hoffmann <address@hidden> writes:

On Do, 2017-03-23 at 13:41 +0100, Markus Armbruster wrote:
Gerd Hoffmann <address@hidden> 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.

Apparently Clang isn't clever enough using an assertion.

I'll resend checking len.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]