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

Re: [Xen-devel] [PATCH 8 of 8] xl: add node-affinity to the output of `xl list`



Dario Faggioli writes ("[PATCH 8 of 8] xl: add node-affinity to the output of 
`xl list`"):
> Node-affinity is now something that is under (some) control of the
> user, so show it upon request as part of the output of `xl list'.
...
> -static void list_domains(int verbose, int context, const libxl_dominfo 
> *info, int nb_domain)
> +static void print_bitmap(uint8_t *map, int maplen, FILE *stream, int 
> cpu_node)
> +{
> +    int i;
> +    uint8_t pmap = 0, bitmask = 0;
> +    int firstset = 0, state = 0;
> +
> +    for (i = 0; i < maplen; i++) {
> +        if (i % 8 == 0) {
> +            pmap = *map++;
> +            bitmask = 1;
> +        } else bitmask <<= 1;
> +
> +        switch (state) {
> +        case 0:
> +        case 2:
> +            if ((pmap & bitmask) != 0) {
> +                firstset = i;
> +                state++;
> +            }
> +            continue;
> +        case 1:
> +        case 3:
> +            if ((pmap & bitmask) == 0) {
> +                fprintf(stream, "%s%d", state > 1 ? "," : "", firstset);
> +                if (i - 1 > firstset)
> +                    fprintf(stream, "-%d", i - 1);
> +                state = 2;
> +            }
> +            continue;
> +        }
> +    }

Is this business with a state variable really the least opaque way of
writing this ?  Oh I see you're just moving it about.  Oh well..

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.