Re: [PATCH v2] host-validate: Improve CPU flags processing

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

 



On Tue, 2016-04-05 at 12:35 +0200, Ján Tomko wrote:
> > +        /* Split the line using " " as a delimiter. The first token
> > +         * will always be ":", but that's okay */
> > +        if (!(tokens = virStringSplitCount(start, " ", 0, &ntokens)))
> > +            continue;
> > +
> > +        /* Go through all flags and check whether one of those we
> > +         * might want to check for later on is present; if that's
> > +         * the case, set the relevant bit in the bitmap */
> > +        for (i = 0; i < ntokens; i++) {
> > +            int value;
> > +
> > +            if ((value = virHostValidateCPUFlagTypeFromString(tokens[i])) >= 0)
> > +                ignore_value(virBitmapSetBit(flags, value));
> >          }
> > +
> > +        virStringFreeListCount(tokens, ntokens);
> >      } while (1);
> 
> We have already found the first 'flags' or 'Features' and parsed all the
> features. I doubt different processors on the system would have
> different features so I'd just use while (0) here.

Yeah, if different CPUs had different features we'd probably
be in for a word of pain anyway.

Turns out that gcc is smart enough to figure out that a
'do {} while (0);' loop is going to be executed only once,
and optimizes it accordingly.

Side effect: the 'continue' instructions behave the same as
the 'break' instructions, and everything stops working :(

I've pushed the patch as-is.

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

--
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]