Re: [PATCH 1/7] trace-cmd lib: Close FDs in create_buffer_recorder_fd2 it allocation fails

Steven Rostedt <[email protected]> Wed, 18 Dec 2024 17:43:23 -0500
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
On Wed, 18 Dec 2024 17:37:31 -0500
Steven Rostedt <[email protected]> wrote:

> No. If a function does not open a file descriptor, it should not close it.
> It's bad programming style if a called function closes a file descriptor on
> error that was passed to it. That can easily introduce new bugs.
> 
> The fix is to not have it close a file descriptor at all!

And this means all the callers should close their fd if the recorder fails.
It should have never done that in the first place. :-/

Oh well, that was written over 10 years ago ;-)

-- Steve