mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:57:44 +00:00
Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
This commit is contained in:
parent
b33a6a443e
commit
5d180d1f99
725 changed files with 3448 additions and 3448 deletions
|
@ -39,17 +39,17 @@
|
|||
void AK::Formatter<Shell::AST::Command>::format(FormatBuilder& builder, const Shell::AST::Command& value)
|
||||
{
|
||||
if (m_sign_mode != FormatBuilder::SignMode::Default)
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
if (m_alternative_form)
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
if (m_zero_pad)
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
if (m_mode != Mode::Default && m_mode != Mode::String)
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
if (m_width.has_value())
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
if (m_precision.has_value())
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
|
||||
if (value.argv.is_empty()) {
|
||||
builder.put_literal("(ShellInternal)");
|
||||
|
@ -93,7 +93,7 @@ void AK::Formatter<Shell::AST::Command>::format(FormatBuilder& builder, const Sh
|
|||
builder.put_i64(close_redir->fd);
|
||||
builder.put_literal(">&-");
|
||||
} else {
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -831,7 +831,7 @@ RefPtr<Value> ContinuationControl::run(RefPtr<Shell> shell)
|
|||
else if (m_kind == Continue)
|
||||
shell->raise_error(Shell::ShellError::InternalControlFlowContinue, {}, position());
|
||||
else
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
return create<ListValue>({});
|
||||
}
|
||||
|
||||
|
@ -900,7 +900,7 @@ RefPtr<Value> DynamicEvaluate::run(RefPtr<Shell> shell)
|
|||
// Strings are treated as variables, and Lists are treated as commands.
|
||||
if (result->is_string()) {
|
||||
auto name_part = result->resolve_as_list(shell);
|
||||
ASSERT(name_part.size() == 1);
|
||||
VERIFY(name_part.size() == 1);
|
||||
return create<SimpleVariableValue>(name_part[0]);
|
||||
}
|
||||
|
||||
|
@ -1418,7 +1418,7 @@ void Execute::for_each_entry(RefPtr<Shell> shell, Function<IterationDecision(Non
|
|||
auto line_end = offset.value();
|
||||
if (line_end == 0) {
|
||||
auto rc = stream.discard_or_error(ifs.length());
|
||||
ASSERT(rc);
|
||||
VERIFY(rc);
|
||||
|
||||
if (shell->options.inline_exec_keep_empty_segments)
|
||||
if (callback(create<StringValue>("")) == IterationDecision::Break) {
|
||||
|
@ -1429,7 +1429,7 @@ void Execute::for_each_entry(RefPtr<Shell> shell, Function<IterationDecision(Non
|
|||
} else {
|
||||
auto entry = ByteBuffer::create_uninitialized(line_end + ifs.length());
|
||||
auto rc = stream.read_or_error(entry);
|
||||
ASSERT(rc);
|
||||
VERIFY(rc);
|
||||
|
||||
auto str = StringView(entry.data(), entry.size() - ifs.length());
|
||||
if (callback(create<StringValue>(str)) == IterationDecision::Break) {
|
||||
|
@ -1515,7 +1515,7 @@ void Execute::for_each_entry(RefPtr<Shell> shell, Function<IterationDecision(Non
|
|||
if (!stream.eof()) {
|
||||
auto entry = ByteBuffer::create_uninitialized(stream.size());
|
||||
auto rc = stream.read_or_error(entry);
|
||||
ASSERT(rc);
|
||||
VERIFY(rc);
|
||||
callback(create<StringValue>(String::copy(entry)));
|
||||
}
|
||||
}
|
||||
|
@ -2082,7 +2082,7 @@ void PathRedirectionNode::highlight_in_editor(Line::Editor& editor, Shell& shell
|
|||
m_path->highlight_in_editor(editor, shell, metadata);
|
||||
if (m_path->is_bareword()) {
|
||||
auto path_text = m_path->run(nullptr)->resolve_as_list(nullptr);
|
||||
ASSERT(path_text.size() == 1);
|
||||
VERIFY(path_text.size() == 1);
|
||||
// Apply a URL to the path.
|
||||
auto& position = m_path->position();
|
||||
auto& path = path_text[0];
|
||||
|
@ -2521,8 +2521,8 @@ RefPtr<Value> Juxtaposition::run(RefPtr<Shell> shell)
|
|||
|
||||
if (left_value->is_string() && right_value->is_string()) {
|
||||
|
||||
ASSERT(left.size() == 1);
|
||||
ASSERT(right.size() == 1);
|
||||
VERIFY(left.size() == 1);
|
||||
VERIFY(right.size() == 1);
|
||||
|
||||
StringBuilder builder;
|
||||
builder.append(left[0]);
|
||||
|
@ -2880,7 +2880,7 @@ RefPtr<Value> VariableDeclarations::run(RefPtr<Shell> shell)
|
|||
{
|
||||
for (auto& var : m_variables) {
|
||||
auto name_value = var.name->run(shell)->resolve_as_list(shell);
|
||||
ASSERT(name_value.size() == 1);
|
||||
VERIFY(name_value.size() == 1);
|
||||
auto name = name_value[0];
|
||||
auto value = var.value->run(shell);
|
||||
shell->set_local_variable(name, value.release_nonnull());
|
||||
|
@ -3063,7 +3063,7 @@ Vector<String> SimpleVariableValue::resolve_as_list(RefPtr<Shell> shell)
|
|||
|
||||
NonnullRefPtr<Value> SimpleVariableValue::resolve_without_cast(RefPtr<Shell> shell)
|
||||
{
|
||||
ASSERT(shell);
|
||||
VERIFY(shell);
|
||||
|
||||
if (auto value = shell->lookup_local_variable(m_name))
|
||||
return value.release_nonnull();
|
||||
|
@ -3150,7 +3150,7 @@ Result<NonnullRefPtr<Rewiring>, String> PathRedirection::apply() const
|
|||
return check_fd_and_return(open(path.characters(), O_RDWR | O_CREAT, 0666), path);
|
||||
}
|
||||
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
PathRedirection::~PathRedirection()
|
||||
|
|
|
@ -285,8 +285,8 @@ private:
|
|||
|
||||
class JobValue final : public Value {
|
||||
public:
|
||||
virtual Vector<String> resolve_as_list(RefPtr<Shell>) override { ASSERT_NOT_REACHED(); }
|
||||
virtual Vector<Command> resolve_as_commands(RefPtr<Shell>) override { ASSERT_NOT_REACHED(); }
|
||||
virtual Vector<String> resolve_as_list(RefPtr<Shell>) override { VERIFY_NOT_REACHED(); }
|
||||
virtual Vector<Command> resolve_as_commands(RefPtr<Shell>) override { VERIFY_NOT_REACHED(); }
|
||||
virtual ~JobValue();
|
||||
virtual bool is_job() const override { return true; }
|
||||
JobValue(RefPtr<Job> job)
|
||||
|
@ -441,7 +441,7 @@ public:
|
|||
}
|
||||
virtual const SyntaxError& syntax_error_node() const
|
||||
{
|
||||
ASSERT(is_syntax_error());
|
||||
VERIFY(is_syntax_error());
|
||||
return *m_syntax_error_node;
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,7 @@ public:
|
|||
|
||||
Vector<Command> to_lazy_evaluated_commands(RefPtr<Shell> shell);
|
||||
|
||||
virtual void visit(NodeVisitor&) { ASSERT_NOT_REACHED(); }
|
||||
virtual void visit(NodeVisitor&) { VERIFY_NOT_REACHED(); }
|
||||
virtual void visit(NodeVisitor& visitor) const { const_cast<Node*>(this)->visit(visitor); }
|
||||
|
||||
enum class Kind : u32 {
|
||||
|
@ -696,7 +696,7 @@ private:
|
|||
NODE(CommandLiteral);
|
||||
virtual void dump(int level) const override;
|
||||
virtual RefPtr<Value> run(RefPtr<Shell>) override;
|
||||
virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override { ASSERT_NOT_REACHED(); }
|
||||
virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override { VERIFY_NOT_REACHED(); }
|
||||
virtual bool is_command() const override { return true; }
|
||||
virtual bool is_list() const override { return true; }
|
||||
|
||||
|
@ -916,7 +916,7 @@ struct HistorySelector {
|
|||
return selector;
|
||||
if (kind == Last)
|
||||
return size - 1;
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
};
|
||||
struct {
|
||||
|
|
|
@ -249,7 +249,7 @@ void Formatter::visit(const AST::CloseFdRedirection* node)
|
|||
|
||||
void Formatter::visit(const AST::CommandLiteral*)
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void Formatter::visit(const AST::Comment* node)
|
||||
|
@ -270,7 +270,7 @@ void Formatter::visit(const AST::ContinuationControl* node)
|
|||
else if (node->continuation_kind() == AST::ContinuationControl::Continue)
|
||||
current_builder().append("continue");
|
||||
else
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
visited(node);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,12 +72,12 @@ public:
|
|||
bool signaled() const { return m_term_sig != -1; }
|
||||
int exit_code() const
|
||||
{
|
||||
ASSERT(exited());
|
||||
VERIFY(exited());
|
||||
return m_exit_code;
|
||||
}
|
||||
int termination_signal() const
|
||||
{
|
||||
ASSERT(signaled());
|
||||
VERIFY(signaled());
|
||||
return m_term_sig;
|
||||
}
|
||||
bool should_be_disowned() const { return m_should_be_disowned; }
|
||||
|
|
|
@ -44,7 +44,7 @@ char Parser::peek()
|
|||
if (at_end())
|
||||
return 0;
|
||||
|
||||
ASSERT(m_offset < m_input.length());
|
||||
VERIFY(m_offset < m_input.length());
|
||||
|
||||
auto ch = m_input[m_offset];
|
||||
if (ch == '\\' && m_input.length() > m_offset + 1 && m_input[m_offset + 1] == '\n') {
|
||||
|
@ -326,7 +326,7 @@ RefPtr<AST::Node> Parser::parse_variable_decls()
|
|||
if (!rest)
|
||||
return create<AST::VariableDeclarations>(move(variables));
|
||||
|
||||
ASSERT(rest->is_variable_decls());
|
||||
VERIFY(rest->is_variable_decls());
|
||||
auto* rest_decl = static_cast<AST::VariableDeclarations*>(rest.ptr());
|
||||
|
||||
variables.append(rest_decl->variables());
|
||||
|
@ -1368,7 +1368,7 @@ RefPtr<AST::Node> Parser::parse_history_designator()
|
|||
{
|
||||
auto rule_start = push_start();
|
||||
|
||||
ASSERT(peek() == '!');
|
||||
VERIFY(peek() == '!');
|
||||
consume();
|
||||
|
||||
// Event selector
|
||||
|
@ -1585,7 +1585,7 @@ RefPtr<AST::Node> Parser::parse_bareword()
|
|||
{
|
||||
restore_to(rule_start->offset, rule_start->line);
|
||||
auto ch = consume();
|
||||
ASSERT(ch == '~');
|
||||
VERIFY(ch == '~');
|
||||
tilde = create<AST::Tilde>(move(username));
|
||||
}
|
||||
|
||||
|
|
|
@ -135,10 +135,10 @@ private:
|
|||
~ScopedOffset()
|
||||
{
|
||||
auto last = offsets.take_last();
|
||||
ASSERT(last == offset);
|
||||
VERIFY(last == offset);
|
||||
|
||||
auto last_line = lines.take_last();
|
||||
ASSERT(last_line == line);
|
||||
VERIFY(last_line == line);
|
||||
}
|
||||
|
||||
Vector<size_t>& offsets;
|
||||
|
|
|
@ -157,7 +157,7 @@ String Shell::prompt() const
|
|||
|
||||
String Shell::expand_tilde(const String& expression)
|
||||
{
|
||||
ASSERT(expression.starts_with('~'));
|
||||
VERIFY(expression.starts_with('~'));
|
||||
|
||||
StringBuilder login_name;
|
||||
size_t first_slash_index = expression.length();
|
||||
|
@ -177,7 +177,7 @@ String Shell::expand_tilde(const String& expression)
|
|||
const char* home = getenv("HOME");
|
||||
if (!home) {
|
||||
auto passwd = getpwuid(getuid());
|
||||
ASSERT(passwd && passwd->pw_dir);
|
||||
VERIFY(passwd && passwd->pw_dir);
|
||||
return String::format("%s/%s", passwd->pw_dir, path.to_string().characters());
|
||||
}
|
||||
return String::format("%s/%s", home, path.to_string().characters());
|
||||
|
@ -186,7 +186,7 @@ String Shell::expand_tilde(const String& expression)
|
|||
auto passwd = getpwnam(login_name.to_string().characters());
|
||||
if (!passwd)
|
||||
return expression;
|
||||
ASSERT(passwd->pw_dir);
|
||||
VERIFY(passwd->pw_dir);
|
||||
|
||||
return String::format("%s/%s", passwd->pw_dir, path.to_string().characters());
|
||||
}
|
||||
|
@ -515,7 +515,7 @@ Shell::Frame Shell::push_frame(String name)
|
|||
|
||||
void Shell::pop_frame()
|
||||
{
|
||||
ASSERT(m_local_frames.size() > 1);
|
||||
VERIFY(m_local_frames.size() > 1);
|
||||
m_local_frames.take_last();
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ Shell::Frame::~Frame()
|
|||
dbgln("Current frames:");
|
||||
for (auto& frame : frames)
|
||||
dbgln("- {:p}: {}", &frame, frame.name);
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
frames.take_last();
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ int Shell::run_command(const StringView& cmd, Optional<SourcePosition> source_po
|
|||
{
|
||||
// The default-constructed mode of the shell
|
||||
// should not be used for execution!
|
||||
ASSERT(!m_default_constructed);
|
||||
VERIFY(!m_default_constructed);
|
||||
|
||||
take_error();
|
||||
|
||||
|
@ -640,7 +640,7 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
|
|||
} else if (rewiring->fd_action == AST::Rewiring::Close::ImmediatelyCloseNew) {
|
||||
fds.add(rewiring->new_fd);
|
||||
} else if (rewiring->fd_action == AST::Rewiring::Close::RefreshNew) {
|
||||
ASSERT(rewiring->other_pipe_end);
|
||||
VERIFY(rewiring->other_pipe_end);
|
||||
|
||||
int pipe_fd[2];
|
||||
int rc = pipe(pipe_fd);
|
||||
|
@ -652,7 +652,7 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
|
|||
rewiring->other_pipe_end->new_fd = pipe_fd[0]; // This fd will be added to the collection on one of the next iterations.
|
||||
fds.add(pipe_fd[1]);
|
||||
} else if (rewiring->fd_action == AST::Rewiring::Close::RefreshOld) {
|
||||
ASSERT(rewiring->other_pipe_end);
|
||||
VERIFY(rewiring->other_pipe_end);
|
||||
|
||||
int pipe_fd[2];
|
||||
int rc = pipe(pipe_fd);
|
||||
|
@ -795,7 +795,7 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
|
|||
tcsetattr(0, TCSANOW, &default_termios);
|
||||
|
||||
if (command.should_immediately_execute_next) {
|
||||
ASSERT(command.argv.is_empty());
|
||||
VERIFY(command.argv.is_empty());
|
||||
|
||||
Core::EventLoop mainloop;
|
||||
setup_signals();
|
||||
|
@ -816,7 +816,7 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
|
|||
jobs.clear();
|
||||
|
||||
execute_process(move(argv));
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
close(sync_pipe[0]);
|
||||
|
@ -924,7 +924,7 @@ void Shell::execute_process(Vector<const char*>&& argv)
|
|||
}
|
||||
_exit(126);
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void Shell::run_tail(const AST::Command& invoking_command, const AST::NodeWithAction& next_in_chain, int head_exit_code)
|
||||
|
@ -998,7 +998,7 @@ NonnullRefPtrVector<Job> Shell::run_commands(Vector<AST::Command>& commands)
|
|||
auto close_redir = (const AST::CloseRedirection*)&redir;
|
||||
dbgln("close fd {}", close_redir->fd);
|
||||
} else {
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1623,7 +1623,7 @@ void Shell::notify_child_event()
|
|||
#ifdef ENSURE_WAITID_ONCE
|
||||
// Theoretically, this should never trip, as jobs are removed from
|
||||
// the job table when waitpid() succeeds *and* the child is dead.
|
||||
ASSERT(!s_waited_for_pids.contains(job.pid()));
|
||||
VERIFY(!s_waited_for_pids.contains(job.pid()));
|
||||
#endif
|
||||
|
||||
int wstatus = 0;
|
||||
|
@ -1641,7 +1641,7 @@ void Shell::notify_child_event()
|
|||
// FIXME: This should never happen, the child should stay around until we do the waitpid above.
|
||||
child_pid = job.pid();
|
||||
} else {
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
if (child_pid == 0) {
|
||||
|
@ -1985,7 +1985,7 @@ SavedFileDescriptors::SavedFileDescriptors(const NonnullRefPtrVector<AST::Rewiri
|
|||
|
||||
auto flags = fcntl(new_fd, F_GETFL);
|
||||
auto rc = fcntl(new_fd, F_SETFL, flags | FD_CLOEXEC);
|
||||
ASSERT(rc == 0);
|
||||
VERIFY(rc == 0);
|
||||
|
||||
m_saves.append({ rewiring.new_fd, new_fd });
|
||||
m_collector.add(new_fd);
|
||||
|
|
|
@ -64,7 +64,7 @@ private:
|
|||
offset -= new_line.line_column;
|
||||
--offset;
|
||||
|
||||
ASSERT(new_line.line_number > 0);
|
||||
VERIFY(new_line.line_number > 0);
|
||||
--new_line.line_number;
|
||||
|
||||
auto line = m_document.line(new_line.line_number);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue