diff --git a/Shell/AST.cpp b/Shell/AST.cpp index 5943f33663b..ac3a6e8352f 100644 --- a/Shell/AST.cpp +++ b/Shell/AST.cpp @@ -2041,24 +2041,24 @@ Vector TildeValue::resolve_as_list(RefPtr shell) return { shell->expand_tilde(builder.to_string()) }; } -Result, String> CloseRedirection::apply() const +Result, String> CloseRedirection::apply() const { - return static_cast>((adopt(*new Rewiring(fd, fd, Rewiring::Close::ImmediatelyCloseDestination)))); + return adopt(*new Rewiring(fd, fd, Rewiring::Close::ImmediatelyCloseDestination)); } CloseRedirection::~CloseRedirection() { } -Result, String> PathRedirection::apply() const +Result, String> PathRedirection::apply() const { - auto check_fd_and_return = [my_fd = this->fd](int fd, const String& path) -> Result, String> { + auto check_fd_and_return = [my_fd = this->fd](int fd, const String& path) -> Result, String> { if (fd < 0) { String error = strerror(errno); dbg() << "open() failed for '" << path << "' with " << error; return error; } - return static_cast>((adopt(*new Rewiring(my_fd, fd, Rewiring::Close::Destination)))); + return adopt(*new Rewiring(my_fd, fd, Rewiring::Close::Destination)); }; switch (direction) { case AST::PathRedirection::WriteAppend: diff --git a/Shell/AST.h b/Shell/AST.h index d70ba1218b1..709a93b7152 100644 --- a/Shell/AST.h +++ b/Shell/AST.h @@ -78,7 +78,7 @@ struct Rewiring : public RefCounted { }; struct Redirection : public RefCounted { - virtual Result, String> apply() const = 0; + virtual Result, String> apply() const = 0; virtual ~Redirection(); virtual bool is_path_redirection() const { return false; } virtual bool is_fd_redirection() const { return false; } @@ -88,7 +88,7 @@ struct Redirection : public RefCounted { struct CloseRedirection : public Redirection { int fd { -1 }; - virtual Result, String> apply() const override; + virtual Result, String> apply() const override; virtual ~CloseRedirection(); CloseRedirection(int fd) : fd(fd) @@ -109,7 +109,7 @@ struct PathRedirection : public Redirection { ReadWrite, } direction { Read }; - virtual Result, String> apply() const override; + virtual Result, String> apply() const override; virtual ~PathRedirection(); PathRedirection(String path, int fd, decltype(direction) direction) : path(move(path)) @@ -123,9 +123,9 @@ private: }; struct FdRedirection : public Redirection { - virtual Result, String> apply() const override + virtual Result, String> apply() const override { - return RefPtr(adopt(*new Rewiring(source_fd, dest_fd, other_pipe_end, action))); + return adopt(*new Rewiring(source_fd, dest_fd, other_pipe_end, action)); } virtual ~FdRedirection(); FdRedirection(int source, int dest, Rewiring::Close close) diff --git a/Shell/Parser.cpp b/Shell/Parser.cpp index ebb10f2bd82..fd434162e5e 100644 --- a/Shell/Parser.cpp +++ b/Shell/Parser.cpp @@ -72,7 +72,7 @@ bool Parser::expect(const StringView& expected) } template -RefPtr Parser::create(Args... args) +NonnullRefPtr Parser::create(Args... args) { return adopt(*new A(AST::Position { m_rule_start_offsets.last(), m_offset }, args...)); } diff --git a/Shell/Parser.h b/Shell/Parser.h index b1476da6074..06c4e7905e9 100644 --- a/Shell/Parser.h +++ b/Shell/Parser.h @@ -65,7 +65,7 @@ private: RefPtr parse_glob(); template - RefPtr create(Args... args); + NonnullRefPtr create(Args... args); bool at_end() const { return m_input.length() <= m_offset; } char peek();