Re: [libvirt] [PATCH v2 6/9] virConnectBaselineCPU public API implementation

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

 



> > +char *
> > +virConnectBaselineCPU(virConnectPtr conn,
> > +                      const char **xmlCPUs,
> > +                      unsigned int ncpus,
> > +                      unsigned int flags)
> > +{
> > +    unsigned int i;
> > +
> > +    VIR_DEBUG("conn=%p, xmlCPUs=%p, ncpus=%u, flags=%u",
> > +              conn, xmlCPUs, ncpus, flags);
> > +    if (xmlCPUs) {
> > +        for (i = 0; i < ncpus; i++)
> > +            VIR_DEBUG("xmlCPUs[%u]=%s", i, xmlCPUs[i]);
> 
>    Hum ... what if xmlCPUs[i] == NULL ... we should not crash there
> maybe this should be tested and that loop being done after
> VIR_IS_CONNECT(conn) check and xmlCPUs == NULL check

I think it's better to keep it just after the first debug print as the purpose
of this loop is to print detailed data about arguments passed to
virConnectBaselineCPU(). However, we shouldn't really crash there. I think

    xmlCPUs[i] ? xmlCPUs[i] : "(null)"

or just printing only non-NULL strings is sufficient.

Jirka

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]