Re: [PATCH v2 06/13] perf header: add struct feat_fd for write

From: David Carrillo-Cisneros
Date: Sun Jun 04 2017 - 21:51:10 EST


On Thu, May 25, 2017 at 1:07 AM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> On Tue, May 23, 2017 at 12:48:46AM -0700, David Carrillo-Cisneros wrote:
>
> SNIP
>
>> @@ -2211,18 +2214,18 @@ static int do_write_feat(int fd, struct perf_header *h, int type,
>> if (!feat_ops[type].write)
>> return -1;
>>
>> - (*p)->offset = lseek(fd, 0, SEEK_CUR);
>> + (*p)->offset = lseek(fd->fd, 0, SEEK_CUR);
>>
>> - err = feat_ops[type].write(fd, h, evlist);
>> + err = feat_ops[type].write(fd, evlist);
>> if (err < 0) {
>> pr_debug("failed to write feature %s\n", feat_ops[type].name);
>>
>> /* undo anything written */
>> - lseek(fd, (*p)->offset, SEEK_SET);
>> + lseek(fd->fd, (*p)->offset, SEEK_SET);
>>
>> return -1;
>> }
>> - (*p)->size = lseek(fd, 0, SEEK_CUR) - (*p)->offset;
>> + (*p)->size = lseek(fd->fd, 0, SEEK_CUR) - (*p)->offset;
>> (*p)++;
>> }
>> return ret;
>> @@ -2232,12 +2235,18 @@ static int perf_header__adds_write(struct perf_header *header,
>> struct perf_evlist *evlist, int fd)
>> {
>> int nr_sections;
>> + struct feat_fd fdd;
>> struct perf_file_section *feat_sec, *p;
>> int sec_size;
>> u64 sec_start;
>> int feat;
>> int err;
>>
>> + fdd = (struct feat_fd){
>> + .fd = fd,
>> + .ph = header,
>> + };
>
> could you unite the naming for struct feat_fd variables?
>
> it's slightly confusing, especialy when you keep the 'fd'
> name in some cases.. ff? ;-)
>
Thank you for the review :) . I'll do the rename.

> jirka