lkml.org 
[lkml]   [2012]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 04/18] perf header: Add HEADER_GROUP_DESC feature
Date
On Thu, 29 Nov 2012 15:43:04 -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Nov 29, 2012 at 03:38:32PM +0900, Namhyung Kim escreveu:
>> From: Namhyung Kim <namhyung.kim@lge.com>
>>
>> Save group relationship information so that it can be restored when
>> perf report is running.
>>
[snip]
>> +static int write_group_desc(int fd, struct perf_header *h __maybe_unused,
>> + struct perf_evlist *evlist)
>> +{
>> + u32 nr_groups = evlist->nr_groups;
>> + struct perf_evsel *evsel;
>> +
>> + do_write(fd, &nr_groups, sizeof(nr_groups));
>> +
>> + list_for_each_entry(evsel, &evlist->entries, node) {
>> + if (perf_evsel__is_group_leader(evsel) &&
>> + evsel->nr_members > 1) {
>> + const char *name = evsel->group_name ?: "{anon_group}";
>> + u32 leader_idx = evsel->idx;
>> + u32 nr_members = evsel->nr_members;
>> +
>> + do_write_string(fd, name);
>> + do_write(fd, &leader_idx, sizeof(leader_idx));
>> + do_write(fd, &nr_members, sizeof(nr_members));
>
> You need to check do_write() return, it can fail. There are some cases
> in header.c that don't check it, those should be eventually fixed, most
> cases check it tho.

Okay.

>
>> + }
>> + }
>> + return 0;
>> +}
[snip]
>> +static int process_group_desc(struct perf_file_section *section __maybe_unused,
>> + struct perf_header *ph, int fd,
>> + void *data __maybe_unused)
>> +{
>> + size_t ret = -1;
>> + u32 i, nr, nr_groups;
>> + struct perf_session *session;
>> + struct perf_evsel *evsel, *leader = NULL;
>> + struct group_desc {
>> + char *name;
>> + u32 leader_idx;
>> + u32 nr_members;
>> + } *desc;
>> +
>> + if (read(fd, &nr_groups, sizeof(nr_groups)) != sizeof(nr_groups))
>
> Please use readn() instead in all read() cases in this function.

Will do.

Thanks,
Namhyung


\
 
 \ /
  Last update: 2012-12-03 03:01    [W:3.772 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site