From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: Re: [PATCH 8 of 8] xl: add node-affinity to the output of `xl list` Date: Fri, 5 Oct 2012 17:36:34 +0100 Message-ID: <20591.3218.46221.931473@mariner.uk.xensource.com> References: <7fba2d9044e720770c25.1349446106@Solace> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <7fba2d9044e720770c25.1349446106@Solace> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Dario Faggioli Cc: Andre Przywara , Ian Campbell , Anil Madhavapeddy , George Dunlap , Andrew Cooper , Juergen Gross , "xen-devel@lists.xen.org" , Jan Beulich , Marcus Granado , Daniel De Graaf , Matt Wilson List-Id: xen-devel@lists.xenproject.org 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.