Everywhere: Use default StringView constructor over nullptr

While null StringViews are just as bad, these prevent the removal of
StringView(char const*) as that constructor accepts a nullptr.

No functional changes.
This commit is contained in:
sin-ack 2022-07-11 20:18:40 +00:00 committed by Andreas Kling
parent c8585b77d2
commit fbc771efe9
16 changed files with 31 additions and 31 deletions

View file

@ -81,7 +81,7 @@ public:
virtual HandlerType type() const override { return HandlerType::IRQHandler; }
virtual StringView purpose() const override { return "IPI Handler"sv; }
virtual StringView controller() const override { return nullptr; }
virtual StringView controller() const override { return {}; }
virtual size_t sharing_devices_count() const override { return 0; }
virtual bool is_shared_handler() const override { return false; }
@ -112,7 +112,7 @@ public:
virtual HandlerType type() const override { return HandlerType::IRQHandler; }
virtual StringView purpose() const override { return "SMP Error Handler"sv; }
virtual StringView controller() const override { return nullptr; }
virtual StringView controller() const override { return {}; }
virtual size_t sharing_devices_count() const override { return 0; }
virtual bool is_shared_handler() const override { return false; }

View file

@ -348,7 +348,7 @@ ErrorOr<void> PerformanceEventBuffer::add_process(Process const& process, Proces
ErrorOr<void> result;
process.for_each_thread([&](auto& thread) {
result = append_with_ip_and_bp(process.pid(), thread.tid().value(),
0, 0, PERF_EVENT_THREAD_CREATE, 0, 0, 0, nullptr);
0, 0, PERF_EVENT_THREAD_CREATE, 0, 0, 0, {});
return result.is_error() ? IterationDecision::Break : IterationDecision::Continue;
});
TRY(result);

View file

@ -34,7 +34,7 @@ public:
if (g_profiling_all_threads) {
VERIFY(g_global_perf_events);
[[maybe_unused]] auto rc = g_global_perf_events->append_with_ip_and_bp(
process.pid(), 0, 0, 0, PERF_EVENT_PROCESS_EXIT, 0, 0, 0, nullptr);
process.pid(), 0, 0, 0, PERF_EVENT_PROCESS_EXIT, 0, 0, 0, {});
}
}
@ -43,7 +43,7 @@ public:
if (thread.is_profiling_suppressed())
return;
if (auto* event_buffer = thread.process().current_perf_events_buffer()) {
[[maybe_unused]] auto rc = event_buffer->append(PERF_EVENT_THREAD_CREATE, thread.tid().value(), 0, nullptr, &thread);
[[maybe_unused]] auto rc = event_buffer->append(PERF_EVENT_THREAD_CREATE, thread.tid().value(), 0, {}, &thread);
}
}
@ -52,7 +52,7 @@ public:
// As an exception this doesn't check whether profiling is suppressed for
// the thread so we can record the thread_exit event anyway.
if (auto* event_buffer = thread.process().current_perf_events_buffer()) {
[[maybe_unused]] auto rc = event_buffer->append(PERF_EVENT_THREAD_EXIT, thread.tid().value(), 0, nullptr, &thread);
[[maybe_unused]] auto rc = event_buffer->append(PERF_EVENT_THREAD_EXIT, thread.tid().value(), 0, {}, &thread);
}
}
@ -62,7 +62,7 @@ public:
return;
if (auto* event_buffer = current_thread.process().current_perf_events_buffer()) {
[[maybe_unused]] auto rc = event_buffer->append_with_ip_and_bp(
current_thread.pid(), current_thread.tid(), regs, PERF_EVENT_SAMPLE, lost_time, 0, 0, nullptr);
current_thread.pid(), current_thread.tid(), regs, PERF_EVENT_SAMPLE, lost_time, 0, 0, {});
}
}
@ -76,7 +76,7 @@ public:
inline static void add_unmap_perf_event(Process& current_process, Memory::VirtualRange const& region)
{
if (auto* event_buffer = current_process.current_perf_events_buffer()) {
[[maybe_unused]] auto res = event_buffer->append(PERF_EVENT_MUNMAP, region.base().get(), region.size(), nullptr);
[[maybe_unused]] auto res = event_buffer->append(PERF_EVENT_MUNMAP, region.base().get(), region.size(), {});
}
}
@ -85,7 +85,7 @@ public:
if (current_thread.is_profiling_suppressed())
return;
if (auto* event_buffer = current_thread.process().current_perf_events_buffer()) {
[[maybe_unused]] auto res = event_buffer->append(PERF_EVENT_CONTEXT_SWITCH, next_thread.pid().value(), next_thread.tid().value(), nullptr);
[[maybe_unused]] auto res = event_buffer->append(PERF_EVENT_CONTEXT_SWITCH, next_thread.pid().value(), next_thread.tid().value(), {});
}
}
@ -94,7 +94,7 @@ public:
if (current_thread.is_profiling_suppressed())
return;
if (auto* event_buffer = current_thread.process().current_perf_events_buffer()) {
[[maybe_unused]] auto res = event_buffer->append(PERF_EVENT_KMALLOC, size, ptr, nullptr);
[[maybe_unused]] auto res = event_buffer->append(PERF_EVENT_KMALLOC, size, ptr, {});
}
}
@ -103,7 +103,7 @@ public:
if (current_thread.is_profiling_suppressed())
return;
if (auto* event_buffer = current_thread.process().current_perf_events_buffer()) {
[[maybe_unused]] auto res = event_buffer->append(PERF_EVENT_KFREE, size, ptr, nullptr);
[[maybe_unused]] auto res = event_buffer->append(PERF_EVENT_KFREE, size, ptr, {});
}
}
@ -113,7 +113,7 @@ public:
return;
if (auto* event_buffer = thread.process().current_perf_events_buffer()) {
[[maybe_unused]] auto rc = event_buffer->append_with_ip_and_bp(
thread.pid(), thread.tid(), regs, PERF_EVENT_PAGE_FAULT, 0, 0, 0, nullptr);
thread.pid(), thread.tid(), regs, PERF_EVENT_PAGE_FAULT, 0, 0, 0, {});
}
}
@ -123,7 +123,7 @@ public:
return;
if (auto* event_buffer = thread.process().current_perf_events_buffer()) {
[[maybe_unused]] auto rc = event_buffer->append_with_ip_and_bp(
thread.pid(), thread.tid(), regs, PERF_EVENT_SYSCALL, 0, 0, 0, nullptr);
thread.pid(), thread.tid(), regs, PERF_EVENT_SYSCALL, 0, 0, 0, {});
}
}
@ -158,7 +158,7 @@ public:
filepath_string_index = registered_result.value();
}
[[maybe_unused]] auto rc = event_buffer->append(PERF_EVENT_READ, fd, size, 0, &thread, filepath_string_index, start_timestamp, result); // wrong arguments
[[maybe_unused]] auto rc = event_buffer->append(PERF_EVENT_READ, fd, size, {}, &thread, filepath_string_index, start_timestamp, result); // wrong arguments
}
inline static void timer_tick(RegisterState const& regs)

View file

@ -15,7 +15,7 @@ ErrorOr<FlatPtr> Process::sys$perf_event(int type, FlatPtr arg1, FlatPtr arg2)
auto* events_buffer = current_perf_events_buffer();
if (!events_buffer)
return 0;
TRY(events_buffer->append(type, arg1, arg2, nullptr));
TRY(events_buffer->append(type, arg1, arg2, {}));
return 0;
}

View file

@ -133,7 +133,7 @@ public:
virtual bool is_shared_handler() const override { return false; }
virtual bool is_sharing_with_others() const override { return false; }
virtual HandlerType type() const override { return HandlerType::IRQHandler; }
virtual StringView controller() const override { return nullptr; }
virtual StringView controller() const override { return {}; }
virtual bool eoi() override;
virtual u32 frequency() const override { return (u32)m_frequency; }

View file

@ -32,8 +32,8 @@ void generate_iterator_implementation(IDL::Interface const&);
int main(int argc, char** argv)
{
Core::ArgsParser args_parser;
StringView path = nullptr;
StringView import_base_path = nullptr;
StringView path;
StringView import_base_path;
bool header_mode = false;
bool implementation_mode = false;
bool constructor_header_mode = false;

View file

@ -163,7 +163,7 @@ StringView Image::table_string(unsigned table_index, unsigned offset) const
VERIFY(m_valid);
auto& sh = section_header(table_index);
if (sh.sh_type != SHT_STRTAB)
return nullptr;
return {};
size_t computed_offset = sh.sh_offset + offset;
if (computed_offset >= m_size) {
if (m_verbose_logging)

View file

@ -23,7 +23,7 @@ HashMap<char, TokenType> Lexer::s_single_char_tokens;
Lexer::Lexer(StringView source, StringView filename, size_t line_number, size_t line_column)
: m_source(source)
, m_current_token(TokenType::Eof, {}, StringView(nullptr), StringView(nullptr), filename, 0, 0, 0)
, m_current_token(TokenType::Eof, {}, {}, {}, filename, 0, 0, 0)
, m_filename(filename)
, m_line_number(line_number)
, m_line_column(line_column)

View file

@ -855,7 +855,7 @@ Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput>
Vector<String> result;
size_t offset { state().instruction_position + 3 };
RegexStringView view = ((input.has_value()) ? input.value().view : nullptr);
RegexStringView view = ((input.has_value()) ? input.value().view : StringView {});
for (size_t i = 0; i < arguments_count(); ++i) {
auto compare_type = (CharacterCompareType)m_bytecode->at(offset++);

View file

@ -32,7 +32,7 @@ char const* Token::name() const
}
Lexer::Lexer()
: GenericLexer(StringView { nullptr })
: GenericLexer(StringView {})
{
}
@ -62,7 +62,7 @@ char Lexer::consume()
void Lexer::reset()
{
m_index = 0;
m_current_token = { TokenType::Eof, 0, StringView(nullptr) };
m_current_token = { TokenType::Eof, 0, {} };
m_previous_position = 0;
}
@ -178,7 +178,7 @@ Token Lexer::next()
return emit_token(TokenType::Char);
}
return Token(TokenType::Eof, m_index, nullptr);
return Token(TokenType::Eof, m_index, {});
}
}

View file

@ -61,7 +61,7 @@ public:
private:
TokenType m_type { TokenType::Eof };
size_t m_position { 0 };
StringView m_value { nullptr };
StringView m_value {};
};
class Lexer : public GenericLexer {
@ -77,7 +77,7 @@ public:
private:
size_t m_previous_position { 0 };
Token m_current_token { TokenType::Eof, 0, StringView(nullptr) };
Token m_current_token { TokenType::Eof, 0, {} };
};
}

View file

@ -169,7 +169,7 @@ ALWAYS_INLINE void Parser::reset()
m_parser_state.lexer.reset();
m_parser_state.current_token = m_parser_state.lexer.next();
m_parser_state.error = Error::NoError;
m_parser_state.error_token = { TokenType::Eof, 0, StringView(nullptr) };
m_parser_state.error_token = { TokenType::Eof, 0, {} };
m_parser_state.capture_group_minimum_lengths.clear();
m_parser_state.capture_groups_count = 0;
m_parser_state.named_capture_groups_count = 0;

View file

@ -101,7 +101,7 @@ protected:
Lexer& lexer;
Token current_token;
Error error = Error::NoError;
Token error_token { TokenType::Eof, 0, StringView(nullptr) };
Token error_token { TokenType::Eof, 0, {} };
ByteCode bytecode;
size_t capture_groups_count { 0 };
size_t named_capture_groups_count { 0 };

View file

@ -34,7 +34,7 @@ public:
pthread_t tid() const { return m_tid; }
private:
explicit Thread(Function<intptr_t()> action, StringView thread_name = nullptr);
explicit Thread(Function<intptr_t()> action, StringView thread_name = {});
Function<intptr_t()> m_action;
pthread_t m_tid { 0 };
String m_thread_name;

View file

@ -67,7 +67,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto& clipboard = GUI::Clipboard::the();
if (watch) {
watch_command.append(nullptr);
watch_command.append({});
clipboard.on_change = [&](String const&) {
// Technically there's a race here...

View file

@ -516,7 +516,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
--argc;
if (StringView { arguments.strings[argc] } != "]")
fatal_error("test invoked as '[' requires a closing bracket ']'");
arguments.strings[argc] = nullptr;
arguments.strings[argc] = {};
}
// Exit false when no arguments are given.