Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752334AbbFYDbJ (ORCPT ); Wed, 24 Jun 2015 23:31:09 -0400 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.230]:43455 "EHLO cdptpa-oedge-vip.email.rr.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751408AbbFYDbC (ORCPT ); Wed, 24 Jun 2015 23:31:02 -0400 Date: Wed, 24 Jun 2015 23:31:43 -0400 From: Steven Rostedt To: Josef Bacik Cc: , Subject: Re: [PATCH V2] trace-cmd: add option to group like comms for profile Message-ID: <20150624233143.2d2373d3@grimm.local.home> In-Reply-To: <1432229408-1479-1-git-send-email-jbacik@fb.com> References: <1432229408-1479-1-git-send-email-jbacik@fb.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-RR-Connecting-IP: 107.14.168.118:25 X-Cloudmark-Score: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1609 Lines: 74 On Thu, 21 May 2015 13:30:08 -0400 Josef Bacik wrote: > +static int compare_groups(const void *a, const void *b) > +{ > + const char *A = a; > + const char *B = b; > + > + return strcmp(A, B); a and b are not strings here. They are group_data pointers. I think what you want is this: static int compare_groups(const void *a, const void *b) { struct group_data * const *A = a; struct group_data * const *B = b; return strcmp((*A)->comm, (*B)->comm); } -- Steve > +} > + > > +static void output_groups(struct handle_data *h) > +{ > + struct trace_hash_item **bucket; > + struct trace_hash_item *item; > + struct group_data **groups; > + int nr_groups = 0; > + int i; > + > + trace_hash_for_each_bucket(bucket, &h->group_hash) { > + trace_hash_for_each_item(item, bucket) { > + nr_groups++; > + } > + } > + > + if (nr_groups == 0) > + return; > + > + groups = malloc_or_die(sizeof(*groups) * nr_groups); > + > + nr_groups = 0; > + > + trace_hash_for_each_bucket(bucket, &h->group_hash) { > + trace_hash_while_item(item, bucket) { > + groups[nr_groups++] = group_from_item(item); > + trace_hash_del(item); > + } > + } > + > + qsort(groups, nr_groups, sizeof(*groups), compare_groups); > + > + for (i = 0; i < nr_groups; i++) { > + output_group(h, groups[i]); > + free_group(groups[i]); > + } > + > + free(groups); > +} > + > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/