qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 01/11] blockjob: remove unnecessary check


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 01/11] blockjob: remove unnecessary check
Date: Wed, 19 Apr 2017 11:16:22 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0

On 04/19/2017 11:12 AM, Paolo Bonzini wrote:
> 
> 
> On 19/04/2017 17:48, Eric Blake wrote:
>>>  bool block_job_user_paused(BlockJob *job)
>>>  {
>> Is it worth using some form of attribute((nonnull)) annotations on
>> various functions, to both state our intentions and let compilers help
>> us catch obvious places where we are violating our intentions?  That's
>> more of a generic question to all of qemu, and doesn't affect your
>> particular patch, other than your patch is an instance where the
>> annotation would be useful if we wanted to use them.
> 
> What kind of bug would the compiler catch?  I suppose Coverity would
> catch all of them, and maybe -flto would as well.

Newer gcc is (finally) getting smarts about warning about passing a
known-NULL value to a function parameter marked nonnull; I think Clang
has been doing it for a while.  Coverity definitely flags mismatches
like that.  Other bugs that can be caught include checking a parameter
for NULL after it has already been declared to be non-null.  And if
nothing else, the documentation factor makes it easier for developers to
remember contracts of various functions.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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