Re: [PATCH 6/8] trace-cmd output: Set file_state of output handle after copy of headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 1, 2021 at 4:38 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>
>
> Now that the input and output handles know the state they are at in reading
> or writing, the tracecmd_copy() has to set the state of the output handle it
> creates.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
> ---
>  lib/trace-cmd/trace-output.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
> index 6d504cbaf133..1156899a85d3 100644
> --- a/lib/trace-cmd/trace-output.c
> +++ b/lib/trace-cmd/trace-output.c
> @@ -1656,6 +1656,8 @@ struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle,
>         if (tracecmd_copy_headers(ihandle, handle->fd) < 0)
>                 goto out_free;
>
> +       handle->file_state = TRACECMD_FILE_CMD_LINES;

Why is the state overwritten here, isn't it more logical to be set in
tracecmd_copy_headers(), by each function that copies a header to set
the relevant state. The last call in tracecmd_copy_headers()
is copy_command_lines(), which should set state to
TRACECMD_FILE_CMD_LINES in case of success.
The state is already TRACECMD_FILE_CMD_LINES
in tracecmd_copy_headers(), but right before its exit it
is overwritten to the old file state. And here again it is
overwritten back to TRACECMD_FILE_CMD_LINES.
May be I miss something here, cannot understand the logic.

> +
>         /* The file is all ready to have cpu data attached */
>         return handle;
>
> --
> 2.30.0
>
>


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



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux