All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH v2 09/10] trace-cmd: Use the new flow when creating output handler
Date: Fri, 26 Nov 2021 15:33:24 +0200	[thread overview]
Message-ID: <CAPpZLN7Jauk8OXZFaCSnzBk58nhvuE6ZdgQc650GvM1MD6eWQA@mail.gmail.com> (raw)
In-Reply-To: <20211123230758.3be21343@rorschach.local.home>

On Wed, Nov 24, 2021 at 6:08 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Thu, 11 Nov 2021 17:07:30 +0200
> "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:
>
> > @@ -4437,6 +4456,30 @@ static void write_guest_file(struct buffer_instance *instance)
> >       free(temp_files);
> >  }
> >
> > +static struct tracecmd_output *create_output(struct common_record_context *ctx)
> > +{
> > +     struct tracecmd_output *out;
> > +     int fd;
> > +
> > +     fd = open(ctx->output, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
>
> I stopped at this patch because I really dislike the above.
>
> Why don't we have:
>
>         tracecmd_output_allocate(file);
>
> and
>         tracecmd_output_allocate_fd(fd);
>
> Where tracecmd_output_allocate(file) does:
>
> struct tracecmd_output *tracecmd_output_allocate(const char *file)
> {
>         int fd;
>
>         fd = open(file, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
>         if (fd < 0)
>                 return NULL;
>         return tracecmd_output_allocate_fd(fd);
> }
>
> ?
>
> Then we could remove a lot of these duplicate opens all over the place.
>
> Although, I'm not sure I like the name allocate. It probably should be called:
>
> tracecmd_output_create();
>
> and we keep tracecmd_output_allocate() as is?
>

 There is already such API, I'll replace that pattern with a call to this:
   struct tracecmd_output *tracecmd_create_init_file(const char *output_file)

> -- Steve
>
>
> > +     if (fd < 0)
> > +             return NULL;
> > +
> > +     out = tracecmd_output_allocate(fd);
> > +     if (!out)
> > +             goto error;
> > +     if (tracecmd_output_write_headers(out, listed_events))
> > +             goto error;
> > +     return out;
> > +error:
> > +     if (out)



-- 
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center

      reply	other threads:[~2021-11-26 14:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 15:07 [PATCH v2 09/10] trace-cmd: Use the new flow when creating output handler Tzvetomir Stoyanov (VMware)
2021-11-24  4:07 ` Steven Rostedt
2021-11-26 13:33   ` Tzvetomir Stoyanov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPpZLN7Jauk8OXZFaCSnzBk58nhvuE6ZdgQc650GvM1MD6eWQA@mail.gmail.com \
    --to=tz.stoyanov@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.