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

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

 



On Wed, 18 Dec 2024 17:37:31 -0500
Steven Rostedt <rostedt@xxxxxxxxxxx> 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




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

  Powered by Linux