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 Tue, Mar 2, 2021 at 5:48 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> On Tue, 2 Mar 2021 16:51:56 +0200
> Tzvetomir Stoyanov <tz.stoyanov@xxxxxxxxx> wrote:
>
> > >         handle->file_state = state;
> >
> > The output handle should have the same state as the input handle,
> > so we can just have:
> >
> >       handle->file_state = tracecmd_get_file_state(ihandle);
> >
> > There is exactly the same use case in tracecmd_get_output_handle_fd(),
> > where the out handle is built on a partially written file.
>
> The above is pretty much exactly what I did, but it eliminates error

There is an error checking, if tracecmd_copy_headers() returns 0 then
the ihandle state must be valid and we can use it safely.
The tracecmd_get_file_state() could fail only in case of a NULL
ihandle pointer.

> checking. Should there be a file_state = TRACECMD_FILE_ERROR ?

file_state should point to the last valid file read / write state, in case of
read / write broken section of the file, the state should not be updated.
The use case for invalid state can be an initial state, before
TRACECMD_FILE_INIT.
May be TRACECMD_FILE_UKOWN, but I cannot find a use case for it
in the current implementation.

>
> -- Steve



-- 
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