[libvirt] [PATCH v14 45/49] add parameter checks to common interfaces
Chunyan Liu
cyliu at suse.com
Thu Mar 13 03:01:07 UTC 2014
2014-03-12 23:11 GMT+08:00 Daniel P. Berrange <berrange at redhat.com>:
> On Fri, Mar 07, 2014 at 06:53:12PM +0800, Chunyan Liu wrote:
> > Check NULL parameter inputs
> >
> > Signed-off-by: Chunyan Liu <cyliu at suse.com>
> > ---
> > src/util/virhostdev.c | 57
> +++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 57 insertions(+)
> >
> > diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
> > index 577de48..5f61bfc 100644
> > --- a/src/util/virhostdev.c
> > +++ b/src/util/virhostdev.c
> > @@ -468,6 +468,11 @@ virHostdevPreparePciHostdevs(virHostdevManagerPtr
> hostdev_mgr,
> > size_t i;
> > int ret = -1;
> >
> > + if (!nhostdevs)
> > + return 0;
>
> This is reasonable because it is an expected case.
>
> > + if (hostdev_mgr == NULL)
> > + return -1;
>
> This is something that should never happen except by programmer
> error, since this is allocated right at libvirtd startup and
> then never changed thereafter.
>
> It is preferrable to use ATTRIBUTE_NONNULL() in the header
> file for these kind of things.
>
Will update.
>
>
> Regards,
> Daniel
> --
> |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/:|
> |: http://libvirt.org -o- http://virt-manager.org:|
> |: http://autobuild.org -o- http://search.cpan.org/~danberr/:|
> |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc:|
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140313/5899d4fc/attachment-0001.htm>
More information about the libvir-list
mailing list