From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754179AbbERSSR (ORCPT ); Mon, 18 May 2015 14:18:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49731 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753126AbbERSSQ (ORCPT ); Mon, 18 May 2015 14:18:16 -0400 Date: Mon, 18 May 2015 20:17:23 +0200 From: Jiri Olsa To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , LKML , David Ahern , Adrian Hunter , Andi Kleen , Frederic Weisbecker , Stephane Eranian Subject: Re: [PATCH 06/40] perf tools: Add HEADER_DATA_INDEX feature Message-ID: <20150518181723.GC16373@krava.redhat.com> References: <1431909055-21442-1-git-send-email-namhyung@kernel.org> <1431909055-21442-7-git-send-email-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1431909055-21442-7-git-send-email-namhyung@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 18, 2015 at 09:30:21AM +0900, Namhyung Kim wrote: SNIP > > +static int process_data_index(struct perf_file_section *section __maybe_unused, > + struct perf_header *ph, int fd, > + void *data __maybe_unused) > +{ > + ssize_t ret; > + u64 nr_idx; > + unsigned i; > + struct perf_file_section *idx; > + > + ret = readn(fd, &nr_idx, sizeof(nr_idx)); > + if (ret != sizeof(nr_idx)) > + return -1; > + > + if (ph->needs_swap) > + nr_idx = bswap_64(nr_idx); > + > + idx = calloc(nr_idx, sizeof(*idx)); > + if (idx == NULL) > + return -1; > + > + for (i = 0; i < nr_idx; i++) { > + ret = readn(fd, &idx[i], sizeof(*idx)); > + if (ret != sizeof(*idx)) missing free(idx); jirka > + return ret; > + > + if (ph->needs_swap) { > + idx[i].offset = bswap_64(idx[i].offset); > + idx[i].size = bswap_64(idx[i].size); > + } > + } > + > + ph->index = idx; > + ph->nr_index = nr_idx; > + return 0; SNIP