[libvirt] [PATCH v4 02/13] Adding virDomainSetMemoryParameters and virDomainGetMemoryParameters API

Daniel P. Berrange berrange at redhat.com
Tue Oct 12 14:52:02 UTC 2010


On Tue, Oct 12, 2010 at 08:16:11AM -0600, Eric Blake wrote:
> On 10/12/2010 08:01 AM, Daniel Veillard wrote:
> >
> >Seems that params<= 0 or a NULL params are errors in this function
> >based on the API description, so I prefer to catch those here and added
> >
> >     if ((nparams<= 0) || (params == NULL)) {
> >         virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
> >         goto error;
> >     }
> 
> Or even one step further, and use annotations to mark the function 
> arguments as ATTRIBUTE_NONNULL to get compiler checking of your logic.

That's only true if the client application has the neccessary compile
time warnings enabled during their build. If you annotate a function
with nonnull, the docs say this activates further compiler optimizations.
So I'd be concerned that annotating the public APIs with  nonnull might
let the compiler optimize away that 'params == NULL' check to nothing.
At which point the app using libvirt would be at risk if they had not
enabled compile warnings to activate the annotation

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list