mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: Remove FIFO::{attach,detach}(Direction)
These functions would have caused a `-Woverloaded-virtual` warning with GCC 13, as they shadow `File::{attach,detach}(OpenFileDescription&)`. Both of these functions had a single call site. This commit inlines `attach` into its only caller, `FIFO::open_direction`. Instead of explicitly checking `is_fifo()` in `~OpenFileDescription` before running the `detach(Direction)` overload, let's just override the regular `detach(OpenFileDescription&)` for `FIFO` to perform this action instead.
This commit is contained in:
parent
f666989c9e
commit
2123fdd678
Notes:
sideshowbarker
2024-07-17 02:55:44 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/2123fdd678 Pull-request: https://github.com/SerenityOS/serenity/pull/18766 Reviewed-by: https://github.com/ADKaster
3 changed files with 10 additions and 20 deletions
|
@ -25,7 +25,12 @@ ErrorOr<NonnullRefPtr<FIFO>> FIFO::try_create(UserID uid)
|
|||
ErrorOr<NonnullRefPtr<OpenFileDescription>> FIFO::open_direction(FIFO::Direction direction)
|
||||
{
|
||||
auto description = TRY(OpenFileDescription::try_create(*this));
|
||||
attach(direction);
|
||||
if (direction == Direction::Reader) {
|
||||
++m_readers;
|
||||
} else if (direction == Direction::Writer) {
|
||||
++m_writers;
|
||||
}
|
||||
evaluate_block_conditions();
|
||||
description->set_fifo_direction({}, direction);
|
||||
return description;
|
||||
}
|
||||
|
@ -73,19 +78,11 @@ FIFO::FIFO(UserID uid, NonnullOwnPtr<DoubleBuffer> buffer)
|
|||
|
||||
FIFO::~FIFO() = default;
|
||||
|
||||
void FIFO::attach(Direction direction)
|
||||
void FIFO::detach(OpenFileDescription& description)
|
||||
{
|
||||
if (direction == Direction::Reader) {
|
||||
++m_readers;
|
||||
} else if (direction == Direction::Writer) {
|
||||
++m_writers;
|
||||
}
|
||||
File::detach(description);
|
||||
|
||||
evaluate_block_conditions();
|
||||
}
|
||||
|
||||
void FIFO::detach(Direction direction)
|
||||
{
|
||||
auto direction = description.fifo_direction();
|
||||
if (direction == Direction::Reader) {
|
||||
VERIFY(m_readers);
|
||||
--m_readers;
|
||||
|
|
|
@ -32,17 +32,12 @@ public:
|
|||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open_direction(Direction);
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open_direction_blocking(Direction);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
|
||||
void attach(Direction);
|
||||
void detach(Direction);
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
private:
|
||||
// ^File
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<struct stat> stat() const override;
|
||||
virtual void detach(OpenFileDescription&) override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override;
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const&) const override;
|
||||
|
|
|
@ -53,8 +53,6 @@ OpenFileDescription::OpenFileDescription(File& file)
|
|||
OpenFileDescription::~OpenFileDescription()
|
||||
{
|
||||
m_file->detach(*this);
|
||||
if (is_fifo())
|
||||
static_cast<FIFO*>(m_file.ptr())->detach(fifo_direction());
|
||||
// FIXME: Should this error path be observed somehow?
|
||||
(void)m_file->close();
|
||||
if (m_inode)
|
||||
|
|
Loading…
Reference in a new issue