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....@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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/