From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422948AbbD2L2s (ORCPT ); Wed, 29 Apr 2015 07:28:48 -0400 Received: from mga01.intel.com ([192.55.52.88]:26950 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422804AbbD2L2p (ORCPT ); Wed, 29 Apr 2015 07:28:45 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,670,1422950400"; d="scan'208";a="487131482" Message-ID: <5540BFEA.8080601@intel.com> Date: Wed, 29 Apr 2015 14:26:34 +0300 From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Jiri Olsa CC: Arnaldo Carvalho de Melo , Peter Zijlstra , linux-kernel@vger.kernel.org, David Ahern , Frederic Weisbecker , Namhyung Kim , Stephane Eranian Subject: Re: [PATCH V3 04/25] perf tools: Add AUX area tracing index References: <1429903807-20559-1-git-send-email-adrian.hunter@intel.com> <1429903807-20559-5-git-send-email-adrian.hunter@intel.com> <20150428120746.GA22258@krava.redhat.com> In-Reply-To: <20150428120746.GA22258@krava.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/04/15 15:07, Jiri Olsa wrote: > On Fri, Apr 24, 2015 at 10:29:46PM +0300, Adrian Hunter wrote: > > SNIP > >> + >> +int auxtrace_index__process(int fd, u64 size, struct perf_session *session, >> + bool needs_swap) >> +{ >> + struct list_head *head = &session->auxtrace_index; >> + u64 nr; >> + >> + if (readn(fd, &nr, sizeof(u64)) != sizeof(u64)) >> + return -1; >> + >> + if (needs_swap) >> + nr = bswap_64(nr); >> + >> + if (sizeof(u64) + nr * sizeof(struct auxtrace_index_entry) != size) >> + return -1; > > so the total nr is only used to double check the data size is correct, > it could be omited and you could use just the size of the section.. > also the auxtrace_index__write would be shorter of one loop > > but no big deal.. just asking ;-) I would like to have it as a check that the file structure is the way it is meant to be. Also I will change it to " > size" so that more stuff can be added to the section in the future.