[libvirt] [PATCH v2] storage: Allow to delete device mapper disk partition

Eric Blake eblake at redhat.com
Wed Feb 9 15:21:40 UTC 2011


On 02/08/2011 08:02 PM, Osier Yang wrote:
> 于 2011年02月09日 01:12, Eric Blake 写道:
>> On 02/08/2011 03:30 AM, Osier Yang wrote:
>>> +bool
>>> +virIsDevMapperDevice(const char *devname)
>>> +{
>>> +    struct stat buf;
>>> +
>>> +    if (devname&&
>>> +        !stat(devname,&buf)&&
>>
>> One other thing - the check for devname being non-NULL is not
>> necessary...
>>
>>> +bool virIsDevMapperDevice(const char *devname);
>>
>> if you add ATTRIBUTE_NONNULL(1) to this declaration.  Given that the
>> only use of this new function to date doesn't pass a NULL pointer, we
>> might as well make that part of the API.
>>
> Yeah, it's more reasonable to add ATTRIBUTE_NONNULL to this internal
> function, but do we need to make change on the API? I'm not sure
> if it will introduce some problem.

Adding ATTRIBUTE_NONNULL _is_ the API change I was referring to - it
simplifies the implementation, and puts a contract on the caller to not
pass NULL.  We can always remove it later (and re-instate the explicit
null check in the implementation) if we find a reason to, since the
function is internal.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110209/1eea15f0/attachment-0001.sig>


More information about the libvir-list mailing list