On Tue, 2 Mar 2021 10:10:24 +0200 Tzvetomir Stoyanov <tz.stoyanov@xxxxxxxxx> wrote: > 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. Also, as I believe you noticed, I saved the state in tracecmd_copy_headers() and restored it. But thinking about this more, I'm not sure I like that, and was thinking of just leaving the state of the input handle in the last state that it was updated in. In other words, I wasn't sure the best way to handle this, and reset the state because the original version didn't modify the state, and I was just keeping that the same. But since the fd is now different, it may be a good idea to change the state of the handle. This was something that I wanted to discuss with you, and I'm glad you brought it up, because I forgot about it ;-) -- Steve